Auth Issues
Use this page when users cannot get into the app, keep landing on the wrong screen, or passkey and OAuth behavior does not match your expectations.
Problem: The User Keeps Getting Sent Back To Login
Section titled “Problem: The User Keeps Getting Sent Back To Login”NuxtBase protects /dashboard, /admin, and /ai routes.
If there is no session, protected routes redirect to /login.
What To Check
Section titled “What To Check”- confirm the request is reaching the same domain that Better Auth is configured for
- confirm cookies are actually being set after login
- check whether the app is switching between different hostnames such as
localhost, an IP, and a tunnel URL
If your auth cookies are being created on one origin and you browse on another,
login can appear to succeed and still send the user back to /login.
Problem: The User Cannot Reach The Dashboard Because Email Verification Blocks Them
Section titled “Problem: The User Cannot Reach The Dashboard Because Email Verification Blocks Them”This is expected behavior for verified-session routes.
In the template:
- no session returns
401 Unauthorized - unverified session returns
403 Email verification required - protected route navigation redirects the user to
/auth/confirm?mode=verify-email
What To Check
Section titled “What To Check”- whether the account actually finished email verification
- whether email sending is working at all
- whether the verification link is pointing at the same public domain the user is browsing
Problem: OAuth Login Lands On /dashboard Instead Of /admin
Section titled “Problem: OAuth Login Lands On /dashboard Instead Of /admin”This behavior is correct in the current template.
OAuth login does not use the same post-login role-routing path as email/password or completed 2FA flows.
That means:
/loginOAuth fallback goes to/dashboard/registerOAuth callback is also set to/dashboard- a platform admin is not automatically redirected to
/adminafter OAuth unless you explicitly pass a safe redirect
Problem: OAuth Callback Works Locally But Fails In Production
Section titled “Problem: OAuth Callback Works Locally But Fails In Production”Most of the time, the callback URL registered with Google or GitHub does not match the actual deployed auth URL.
Fix Checklist
Section titled “Fix Checklist”BETTER_AUTH_URLmust use the real production origin- the OAuth provider console must use the same callback host
- if you changed domains recently, remove old localhost or preview callback entries that you are no longer testing
Problem: Passkeys Work Locally But Fail After Deploy
Section titled “Problem: Passkeys Work Locally But Fail After Deploy”Passkeys are extremely sensitive to domain configuration.
The main trap is leaving:
BETTER_AUTH_PASSKEY_RP_ID=localhostin production.
In NuxtBase, explicit BETTER_AUTH_PASSKEY_RP_ID wins over hostname fallback.
So if that value is still set to localhost, passkey registration and login can
stay bound to the wrong relying party.
Use one of these approaches:
- set
BETTER_AUTH_PASSKEY_RP_IDto your real production hostname - or remove it entirely and let the template derive it from the production auth URL/site URL
Problem: Admin Users Reach /dashboard Instead Of /admin
Section titled “Problem: Admin Users Reach /dashboard Instead Of /admin”This depends on how the user signed in.
- standard auth-route handling for authenticated users can redirect verified
platform admins to
/admin - OAuth default fallback still lands on
/dashboard
So the same admin account can see different landing behavior depending on the entry path.
Problem: 2FA Codes Keep Failing
Section titled “Problem: 2FA Codes Keep Failing”Common causes:
- using an expired TOTP code
- trying to disable OAuth 2FA when it is not enabled
- using a code from a different authenticator seed than the one currently saved
If the API returns Invalid verification code, treat it as a real verification
failure first, not as a UI bug.
Fastest Way To Debug Auth
Section titled “Fastest Way To Debug Auth”- confirm the current public domain and
BETTER_AUTH_URL - confirm the user has a real session cookie
- confirm email verification state
- confirm whether the user came through password, OAuth, passkey, or 2FA
- only then debug role-based redirects