Menu

Next.js + Supabase Auth Cookies: 6 Checks That Stop Silent Logouts
πŸ“°

Next.js + Supabase Auth Cookies: 6 Checks That Stop Silent Logouts

DEV Community: nextjsΒ·Sora2 Hub TeamΒ·11 days ago
#JcqdSrk2
#devtonextjs#devto#dev#production#cookie
Reading 0:00
15s threshold

AI-scaffolded Next.js apps often work on localhost and then log users out on the first production visit. The UI looks fine. The session is gone. Nine times out of ten the bug is cookie config, middleware refresh, or a Preview/Production env mismatch β€” not "Supabase is down."

Use this checklist before you point real users at the deploy.

1. Match cookie domain to the real host

If the app lives on app.example.com , the auth cookie domain has to cover that host. A cookie set for localhost or a bare apex while users hit a subdomain looks like a random logout after deploy.

Check:

Production host vs cookie Domain

Whether you need a leading-dot parent domain for subdomains

That Preview deployments are not accidentally writing Production cookie settings

2. Use Secure + SameSite correctly

Production must set Secure cookies over HTTPS.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.