Auth Flow
Authentication spans both projects. The frontend runs NextAuth (sign-in UI, magic-link send, OAuth dance, session callback). The backend stores users + sessions + accounts + verification tokens, and validates Bearer-authed requests. They never share a database client: every adapter call goes over HTTP.
The bearer session token never reaches client JavaScript. NextAuth's httpOnly session cookie holds the token; server-side code reads it via next/headers and forwards it as Authorization: Bearer ... to the backend. Client components fetch via Server Actions or receive RSC-fetched props; they never see the bearer themselves.
Pages
- The Two Sign-In Flows
- Signing Out
- Frontend: NextAuth Setup
- Backend: Validating the Token
- Security Notes
Related
- Architecture - System overview and module structure
- Adding a Module - How to add guards to new routes
- Environment Variables - Auth-related env vars (
AUTH_SECRET,INTERNAL_API_TOKEN, OAuth, SMTP)