Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

Why does my app keep redirecting to login?

Last checked 31 Aug 2026

Short answer

This is almost always a session or route-guard bug: either the auth session isn't persisting, or a protected route checks auth state before it's loaded, so it bounces back to login even when signed in.

Why the redirect loop happens

Lovable Cloud (and connected Supabase projects) use auth tokens stored in the browser to know a user is signed in. A redirect loop to login usually means one of:

  • The app checks session or user before Supabase has finished loading it (a race condition on first render).
  • The session token isn't being persisted (e.g. cookies/local storage blocked, or an incognito/testing quirk).
  • Your protected route wrapper redirects on any falsy user state, including the brief "loading" state, instead of waiting.
  • The redirect target itself is behind the same guard, so it loops.

How to fix it

  1. Ask Lovable: "Show me the protected route component and how it checks auth state."
  2. Confirm it distinguishes three states: loading, signed-in, signed-out — and only redirects once loading is false.
  3. Check that the login page itself isn't wrapped in the same auth guard.
  4. Clear cookies/local storage and test a fresh sign-in end to end, then test a hard refresh while logged in.

Add a loading state to my auth check so protected routes wait for the session to finish loading before redirecting to login.

What usually goes wrong

  • Testing in an environment that blocks third-party cookies or local storage (some in-app browsers do this).
  • Multiple redirect rules stacked (e.g. router-level guard plus a component-level guard) fighting each other.
  • Environment/config mismatch after connecting a custom domain — see why-does-my-domain-show-a-404-or-403-error for domain-specific auth issues.

Testing properly

Use a private/incognito window for each test so old sessions don't mask the bug. See how-do-i-test-authentication-properly for a fuller checklist.

Sources

Was this answer helpful?

Related questions

Website made, maintained and hosted by PromptSites.com

PromptSites logo