Authentication Issues
Infinite redirect loop
Symptoms: Browser keeps redirecting between/auth/login and /auth/callback.
Causes & Solutions:
Missing callback URL in Auth0 Dashboard
Missing callback URL in Auth0 Dashboard
- Go to Applications
- Select your application
- Add your callback URL to Allowed Callback URLs:
- Local:
http://localhost:3000/auth/callback - Production:
https://yourdomain.com/auth/callback
- Local:
- Add your logout URL to Allowed Logout URLs:
- Local:
http://localhost:3000 - Production:
https://yourdomain.com
- Local:
Middleware matcher too restrictive
Middleware matcher too restrictive
/auth/* routes, authentication won’t work.Base path misconfiguration
Base path misconfiguration
basePath, ensure NEXT_PUBLIC_BASE_PATH is set:/dashboard/auth/login, /dashboard/auth/callback, etc.”Invalid state” error
Error code:invalid_state
Causes & Solutions:
Cookie not persisting between requests
Cookie not persisting between requests
Clock skew between client and server
Clock skew between client and server
Concurrent authentication attempts
Concurrent authentication attempts
enableParallelTransactions is enabled (default):Session not persisting after login
Symptoms: User successfully logs in butgetSession() returns null.
Causes & Solutions:
Cookie too large (>4KB)
Cookie too large (>4KB)
beforeSessionSaved hook error
beforeSessionSaved hook error
beforeSessionSaved hook throws an error, the session won’t be saved.Fix: Add error handling:Secure cookie on HTTP
Secure cookie on HTTP
Token Issues
”Missing refresh token” error
Error code:missing_refresh_token
Causes & Solutions:
offline_access scope not requested
offline_access scope not requested
offline_access scope.Fix:Refresh tokens disabled in Auth0
Refresh tokens disabled in Auth0
- Go to Applications
- Select your application
- Go to Advanced Settings > Grant Types
- Enable Refresh Token
Social connection doesn't support refresh tokens
Social connection doesn't support refresh tokens
Access token expired
Symptoms: API calls fail with 401 Unauthorized. Solutions:Automatic refresh (server-side)
Automatic refresh (server-side)
Proactive refresh
Proactive refresh
Handle refresh failures
Handle refresh failures
MFA required unexpectedly
Error code:mfa_required
Causes & Solutions:
Tenant requires MFA step-up
Tenant requires MFA step-up
Token lifetime exceeded
Token lifetime exceeded
Configuration Issues
SDK configuration warnings
Symptoms: Console warnings about missing configuration. Solutions:Missing required environment variables
Missing required environment variables
AUTH0_SECRET:Invalid domain format
Invalid domain format
App base URL misconfiguration
App base URL misconfiguration
APP_BASE_URL:“Discovery failed” error
Error code:discovery_error
Causes & Solutions:
Invalid Auth0 domain
Invalid Auth0 domain
Network/firewall blocking Auth0
Network/firewall blocking Auth0
- Check firewall rules
- Verify DNS resolution
- Test connectivity:
ping your-tenant.us.auth0.com
HTTP timeout too short
HTTP timeout too short
Next.js Specific Issues
Middleware not running
Symptoms: Auth routes don’t work. Solutions:Middleware file location
Middleware file location
- File:
middleware.tsin project root (orsrc/middleware.tsif usingsrc/directory)
- File:
proxy.tsin project root (orsrc/proxy.ts) - Note:
middleware.tsstill works but only on Edge runtime
Matcher configuration
Matcher configuration
Multiple middleware files
Multiple middleware files
Client-side useUser returns undefined
Symptoms: useUser() hook returns undefined after successful login.
Solutions:
Missing Auth0Provider
Missing Auth0Provider
Auth0Provider:useUser in Server Component
useUser in Server Component
useUser is a client hook. Use getSession in Server Components:Build errors with DPoP
Symptoms: Build fails when using DPoP features. Solutions:Edge runtime compatibility
Edge runtime compatibility
CryptoKey serialization
CryptoKey serialization
Performance Issues
Slow authentication
Solutions:Enable connection caching
Enable connection caching
Reduce token size
Reduce token size
- Remove unnecessary scopes
- Use shorter custom claim names
- Avoid large custom claims
Use stateful sessions for large sessions
Use stateful sessions for large sessions
High memory usage
Solutions:Instantiate Auth0Client once
Instantiate Auth0Client once
Disable rolling sessions if not needed
Disable rolling sessions if not needed
Debugging Tips
Enable verbose logging
Enable verbose logging
Inspect cookies
Inspect cookies
Check Auth0 logs
Check Auth0 logs
- Go to Monitoring > Logs
- Filter by application
- Look for failed login attempts, errors
Verify OIDC configuration
Verify OIDC configuration
authorization_endpointtoken_endpointjwks_uri- Supported
grant_types
Getting Help
If you’re still experiencing issues:- Check existing issues: GitHub Issues
- Search documentation: Auth0 Docs
- Ask the community: Auth0 Community
- Report bugs: New Issue
- SDK version (
@auth0/nextjs-auth0version) - Next.js version
- Node.js version
- Minimal reproduction code
- Error messages with stack traces
- Steps to reproduce