Supabase redirects to localhost:3000 after login or email confirmation ('requested path is invalid')
Symptoms
- A user signs up or clicks the confirmation email and lands on http://localhost:3000, a dead page on their own machine
- Supabase shows 'requested path is invalid'
- Google OAuth sign-in bounces back to the wrong URL
- The login loop variant: sign-in appears to succeed on the production domain, then immediately returns to the login screen
Why it happens
Site URL still points at the localhost default
Supabase's Auth Site URL defaults to http://localhost:3000 and is used as the redirect target for confirmation emails, password resets, and OAuth whenever no explicit redirectTo is given, or the given one is not allow-listed.
The Redirect URLs allow-list is missing your environments
Lovable preview URLs and the production domain must be on the Redirect URLs allow-list. 'Requested path is invalid' means the requested redirect was not on that list.
Google OAuth has its own allow-lists
Google needs the production origin in its authorized JavaScript origins and the Supabase callback URL in its authorized redirect URIs, separately from anything you configure in Supabase.
How to fix it
- Set the Site URL to productionIn Supabase, go to Authentication > URL Configuration and set Site URL to your real production URL, either your custom domain or the *.lovable.app URL. The default is http://localhost:3000, and that default is exactly where your users are being sent.
- Allow-list every environment in Redirect URLsAdd the Lovable preview URL, the published lovable.app URL, and your custom domain to Redirect URLs. Wildcards like https://*.lovable.app/** are accepted. 'Requested path is invalid' means the redirect the app asked for was not on this list.
- Pass redirectTo explicitly in codeOn signUp and OAuth calls, pass emailRedirectTo / redirectTo explicitly, for example redirectTo: window.location.origin, so the flow never falls back to the Site URL. Lovable's Supabase auth guide recommends this.
- Fix Google OAuth's own allow-listsIn Google Cloud Console, add your production domain to Authorized JavaScript origins and add the Supabase callback URL, https://<project-ref>.supabase.co/auth/v1/callback, to Authorized redirect URIs. Google enforces these separately from Supabase's list.
- Save, then retest with a fresh signupClick Save in Supabase; unsaved URL configuration is a common miss. Then test with a brand-new signup, because old confirmation emails still contain the old redirect and will keep landing on localhost no matter what you fix.
- Chase the login loop variantIf sign-in succeeds on production and immediately bounces back to the login screen, confirm the domain serving the app exactly matches an allow-listed URL, including https and any www difference.
How to prevent it
- Set Site URL and Redirect URLs the day you connect Supabase auth, before the first real signup.
- Pass redirectTo: window.location.origin on every auth call so environment changes cannot strand users.
- Add each new environment (preview, published URL, custom domain) to Redirect URLs the moment it exists.
- After any auth URL change, test with a fresh signup; old emails carry old links.
Tools that actually fix this
Recommended because they address the failure mode above, not because of the payout. Some are affiliate links; see how we choose.
If your AI-built app uses Supabase, Row Level Security is the actual fix for exposed data, and it is free. The dashboard's Security Advisor lists every table you left open.
Try Supabase →Drop-in authentication that handles sessions, tokens, and protected routes properly, so you stop shipping the hand-rolled auth an AI guessed at. Generous free tier for a real app.
Try Clerk →Frequently asked questions
Why does Supabase redirect my users to localhost:3000?
Supabase's Auth Site URL defaults to http://localhost:3000, and it is used as the redirect target for confirmation emails, password resets, and OAuth whenever no explicit redirectTo is provided or the provided one is not allow-listed. Your production users get sent to a dead page on their own machine. Set Site URL to your production domain and add every environment to the Redirect URLs allow-list under Authentication > URL Configuration.
What does 'requested path is invalid' mean in Supabase?
'Requested path is invalid' means the redirect URL your app requested is not on Supabase's Redirect URLs allow-list under Authentication > URL Configuration. Add the exact URL, or a wildcard pattern like https://*.lovable.app/**, then save. Retest with a fresh signup, because previously sent emails still carry the rejected link.
Why does Google login not work in my Lovable app?
Google OAuth needs its own configuration in Google Cloud Console on top of Supabase's: your production domain must be in Authorized JavaScript origins, and the Supabase callback URL (https://<project-ref>.supabase.co/auth/v1/callback) must be in Authorized redirect URIs. If either is missing, the sign-in bounces back to the wrong URL. Supabase's Redirect URLs list must also include your production domain.
Why do users log in successfully and then land back on the login screen?
This login loop usually means the domain serving the app does not exactly match an allow-listed URL, including the https scheme and any www prefix. Sign-in appears to succeed on the production domain, but the redirect lands somewhere the app cannot pick the session up. Verify that the exact production URL, with protocol and subdomain, is in Supabase's Redirect URLs and matches what users actually visit.
Sources
- Supabase docs: Redirect URLs
- Supabase GitHub discussion #26483
- Supabase GitHub discussion #30394
- Ishwar Rimal: Fixing the 'login with Google' issue in Lovable with Supabase
- Lovable blog: Supabase authentication step by step
- AppStuck: Lovable troubleshooting guide, the 10 most common errors (2026)
Related errors
Lovable custom domain not working: stuck on 'Verifying' or SSL certificate error
Bolt.new + Supabase: 403 Forbidden, data not saving, or the wrong project connected
'new row violates row-level security policy' in Supabase (403 / error 42501)
v0 environment variables undefined: API routes 500 in production but work in preview
Lovable white screen: blank preview or published app shows nothing
The Vibe Oops briefing
One email when something ships to production that should not have. New incidents, new error guides, no filler.