You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In server handlers, pass `event` to `serverAuth(event)` so request URL detection can run. In non-request contexts (seed scripts, tasks, startup plugins), the module uses environment/platform fallbacks.
152
+
151
153
Set an explicit site URL in `nuxt.config.ts` for deterministic OAuth callbacks and origin checks:
Copy file name to clipboardExpand all lines: docs/content/2.core-concepts/1.server-auth.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: serverAuth()
3
3
description: When to reach for the full Better Auth server instance.
4
4
---
5
5
6
-
`serverAuth(event?)` returns the Better Auth instance (module-level singleton). Pass the event for accurate URL detection on first initialization. Prefer the helper utilities for common checks, and reach for`serverAuth()`when you need the full Better Auth API or plugin-specific endpoints.
6
+
`serverAuth(event?)` returns the Better Auth instance (module-level singleton). In Nitro handlers, you should pass `event` so the module can resolve request-aware base URLs on initialization. Outside request contexts (seed scripts, tasks, plugins), you can call`serverAuth()`without an event.
Copy file name to clipboardExpand all lines: docs/content/5.api/2.server-utils.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ await auth.api.getSession({
34
34
```
35
35
36
36
::note
37
-
Use `serverAuth()` to access advanced Better Auth features not exposed by the helper wrappers.
37
+
Use `serverAuth(event)`in request handlers to access advanced Better Auth features not exposed by the helper wrappers. In non-request contexts, you can call `serverAuth()` without an event.
Copy file name to clipboardExpand all lines: docs/content/6.troubleshooting/1.faq.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,8 @@ Restart dev and inspect [http://localhost:3000/api/_better-auth/config](http://l
91
91
92
92
- Verify `config.server.baseURL` matches your local origin exactly.
93
93
- Verify `config.server.trustedOrigins` includes your local origin.
94
+
95
+
When `runtimeConfig.public.siteUrl` points to production during local development, the module still adds local dev origins to `trustedOrigins` (request origin plus localhost fallback). This supports `--host` and LAN testing as long as your request origin is stable.
0 commit comments