Skip to content

docs: fix better-auth tutorial #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions docs/integrations/better-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,7 @@ Then we can access Better Auth with `http://localhost:3000/api/auth`.

### Custom endpoint

We recommended setting a prefix path for when using [mount](/patterns/mount.html).

```ts [index.ts]
import { Elysia } from 'elysia'

const app = new Elysia()
.mount('/auth', auth.handler) // [!code ++]
.listen(3000)

console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
)
```

Then we can access Better Auth with `http://localhost:3000/auth/api/auth`.

But the URL looks redundant, we can customize the `/api/auth` prefix to something else in Better Auth instance.
We can customize the `/api/auth` prefix to something else in Better Auth instance.

```ts
import { betterAuth } from 'better-auth'
Expand All @@ -82,13 +66,11 @@ import { passkey } from 'better-auth/plugins/passkey'
import { Pool } from 'pg'

export const auth = betterAuth({
basePath: '/api' // [!code ++]
basePath: '/auth' // [!code ++]
})
```

Then we can access Better Auth with `http://localhost:3000/auth/api`.

Unfortunately, we can't set `basePath` of a Better Auth instance to be empty or `/`.
Then we can access Better Auth with `http://localhost:3000/auth`.

## Swagger / OpenAPI

Expand Down