Fix Supabase Session Persistence
Budget: $10 – $30 USD
My NextJS real-estate platform uses Supabase Auth and runs flawlessly on localhost, yet once deployed to Vercel the authenticated session vanishes unpredictably. Login and logout calls succeed, so the only culprit left is session persistence. Because I wrote a fully custom session handler on top of the Supabase client, I suspect a race condition, storage-key mismatch, or server / client edge-function nuance that shows up only in production.
What I need right now is a concise audit of the auth flow, a solid diagnosis, and a patch that restores rock-solid session continuity for every user on the live domain.
Key context
• Stack: NextJS 13 (App Router), Supabase JavaScript SDK, Vercel edge runtime.
• Current behaviour: user token occasionally drops during navigation or a page reload; a manual refresh may or may not restore it. No pattern, purely production-only.
• Local build: stable.
Deliverables (acceptance criteria)
• Root cause explained in a short note.
• Code changes or configuration tweaks pushed to a PR and tested on a preview deployment.
• Verified, continuous session retention on the production URL across page loads and route changes.
• Guidance on any long-term best practices affected by the fix.
Please be comfortable tracing Supabase’s `supabase.auth.getSession()` lifecycle, browser storage, middleware cookies, and Vercel edge nuances. I can grant access to the repo and a staging environment the moment we start.
What I need right now is a concise audit of the auth flow, a solid diagnosis, and a patch that restores rock-solid session continuity for every user on the live domain.
Key context
• Stack: NextJS 13 (App Router), Supabase JavaScript SDK, Vercel edge runtime.
• Current behaviour: user token occasionally drops during navigation or a page reload; a manual refresh may or may not restore it. No pattern, purely production-only.
• Local build: stable.
Deliverables (acceptance criteria)
• Root cause explained in a short note.
• Code changes or configuration tweaks pushed to a PR and tested on a preview deployment.
• Verified, continuous session retention on the production URL across page loads and route changes.
• Guidance on any long-term best practices affected by the fix.
Please be comfortable tracing Supabase’s `supabase.auth.getSession()` lifecycle, browser storage, middleware cookies, and Vercel edge nuances. I can grant access to the repo and a staging environment the moment we start.
Related categories:
JavaScript
Debugging
Web Development
Frontend Development
Edge Computing
API Integration
Next.js
Vercel