Nuxt & Universal SSR (50 Qs)•Part 3: Advanced Internals, Performance & Production (Senior / Staff)
What is the recommended Authentication Architecture in Nuxt 3?
senior LevelFormsPerformanceSecurity & Auth
In Simple Words:
Client-side tokens in localStorage are vulnerable to XSS and invisible to the Node SSR server, causing flash of unauthorized content.
Production Best Practice:
- HTTP-Only, Secure, SameSite Cookies: Server sets encrypted session/JWT cookies.
- Universal Request Interception: During SSR, Nuxt's server passes the
Cookieheader to downstream microservices usinguseRequestFetch(). - Client Route Guard & Server Middleware:
server/middleware/auth.tsverifies token before SSR render.middleware/auth.global.tsprotects client transitions.