SvelteKit Supabase with SSR authentication not working in production

Information - Website: schaaponline-web.pages.dev - Deployment ID: 8add7df8 - Account ID: 032bf2ee555ece960d04c403e0d190e5 - Error: Error: Redirect loop at Y (entry.B2BMVBJ7.js:1:18097) Background The website in question is developed in the SvelteKit framework and is deployed to Cloudflare Pages. The back-end is hosted at Supabase. Once a user visits the / route, they are redirected to either the /login or the /dashboard route, depending on the existence of a session. If the user visits the /login route and has a session, they are then redirected to the / route and shortly after the /dashboard route. If the user visits the /dashboard route and has no session, they are redirected to the /login route. The above scenarios work as expected locally. Problem When visiting the website, the user is redirected to the /login route as expected, but will enter a redirection loop after logging in. It will repeat the sequence / -> /dashboard -> /login infinitely. This is because the #getSession() method returns null when inside the (user) group. This is only the case on production, but not in a local environment. I am not sure where the problem lies, but I'm assuming it has something to do with Cloudflare. If I haven't provided enough background information, please let me know. Does anyone know what could be the issue?
1 Reply
Bloedarend
BloedarendOP9mo ago
Don't think this is directly a Cloudflare issue, since I've just tried deploying it to Vercel. Perhaps it has something to do with a pages environment? Solved the issue, but not sure how. Could possibly have had to do with prerender. I merged another branch into production where prerender had been turned off for the dashboard route.
Want results from more Discord servers?
Add your server