diff --git a/docs/content/docs/concepts/database.mdx b/docs/content/docs/concepts/database.mdx
index 480a233241..2ff16e398a 100644
--- a/docs/content/docs/concepts/database.mdx
+++ b/docs/content/docs/concepts/database.mdx
@@ -317,7 +317,7 @@ Table Name: `session`
{
name: "id",
type: "string",
- description: "Unique identifier for each session",
+ description: "Unique identifier for each session. This is used as the session token.",
isPrimaryKey: true
},
{
diff --git a/docs/content/docs/installation.mdx b/docs/content/docs/installation.mdx
index aee1f16753..d67f3a498b 100644
--- a/docs/content/docs/installation.mdx
+++ b/docs/content/docs/installation.mdx
@@ -32,19 +32,12 @@ BETTER_AUTH_SECRET=
```
-2. **Set Base URL**
+2. **Set Base URL (optional)**
```txt title=".env"
BETTER_AUTH_URL=http://localhost:3000 #Base URL of your app
```
-3. **Trusted Origins (optional)**
-
-If the requests are coming from different origins (not the base url), you can add them to the trusted origins.
-
-```txt title=".env"
-BETTER_AUTH_TRUSTED_ORIGINS="http://localhost:3000,https://example.com" //Add your trusted origins here
-```
@@ -55,9 +48,9 @@ Create a file named `auth.ts` in one of these locations:
- `lib/` folder
- `utils/` folder
-You can also nest any of these folders under `src/` or `app/` folder. (e.g. `src/lib/auth.ts`, `app/lib/auth.ts`).
+You can also nest any of these folders under `src/`, `app/` or `server/` folder. (e.g. `src/lib/auth.ts`, `app/lib/auth.ts`).
-And in this file, import Better Auth and create your instance. Make sure to export the auth instance with the variable name `auth` or as a `default` export.
+And in this file, import Better Auth and create your auth instance. Make sure to export the auth instance with the variable name `auth` or as a `default` export.
```ts title="auth.ts"
import { betterAuth } from "better-auth";
@@ -193,7 +186,7 @@ If your database isn’t supported by Kysely, you can use an adapter to connect.
npx @better-auth/cli generate
```
- **Migrate**: Directly creates the required tables in the database. (only available for Kysely adapter)
+ **Migrate**: Directly creates the required tables in the database. (only available for built-in Kysely adapter)
```bash title="Terminal"
npx @better-auth/cli migrate
@@ -244,7 +237,7 @@ Create a new file or route in your framework's designated catch-all route handle
Better Auth supports any backend framework with standard Request and Response objects and offers helper functions for popular frameworks.
-
+
```ts title="/app/api/auth/[...all]/route.ts"
import { auth } from "@/lib/auth"; // path to your auth file
@@ -340,6 +333,28 @@ Better Auth supports any backend framework with standard Request and Response ob
};
```
+
+ ```ts
+ import { Elysia } from "elysia";
+ import { auth } from "./auth";
+
+ const betterAuthView = (context: Context) => {
+ const BETTER_AUTH_ACCEPT_METHODS = ["POST", "GET"]
+ // validate request method
+ if(BETTER_AUTH_ACCEPT_METHODS.includes(context.request.method)) {
+ return auth.handler(context.request);
+ } else {
+ context.error(405)
+ }
+ }
+
+ const app = new Elysia().all("/api/auth/*", betterAuthView).listen(3000);
+
+ console.log(
+ `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
+ );
+ ```
+
diff --git a/docs/content/docs/integrations/elysia.mdx b/docs/content/docs/integrations/elysia.mdx
index dcfa1e9cf0..a506d914b4 100644
--- a/docs/content/docs/integrations/elysia.mdx
+++ b/docs/content/docs/integrations/elysia.mdx
@@ -31,7 +31,6 @@ const app = new Elysia().all("/api/auth/*", betterAuthView).listen(3000);
console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
);
-
```
### Middleware
diff --git a/packages/better-auth/src/init.ts b/packages/better-auth/src/init.ts
index a17f288536..04830c24a4 100644
--- a/packages/better-auth/src/init.ts
+++ b/packages/better-auth/src/init.ts
@@ -21,7 +21,6 @@ import {
} from "./cookies";
import { createLogger, logger } from "./utils/logger";
import { socialProviderList, socialProviders } from "./social-providers";
-import { BetterAuthError } from "./error";
import type { OAuthProvider } from "./oauth2";
import { generateId } from "./utils";
@@ -33,12 +32,6 @@ export const init = async (options: BetterAuthOptions) => {
const { kysely: db } = await createKyselyAdapter(options);
const baseURL = getBaseURL(options.baseURL, options.basePath);
- if (!baseURL) {
- logger.error(
- "Base URL can not be empty. Please add `BETTER_AUTH_URL` in your environment variables or pass it your auth config.",
- );
- }
-
const secret =
options.secret ||
env.BETTER_AUTH_SECRET ||