Home / Errors / Supabase / auth-redirect-localhost

Supabase redirects to localhost:3000 after login or email confirmation ('requested path is invalid')

Supabase Easy 10-30 minutes Last verified Jul 17, 2026
The fix  Open Supabase, Authentication > URL Configuration. Set Site URL to your real production URL and add every environment (Lovable preview, published lovable.app URL, custom domain) to Redirect URLs; wildcards like https://*.lovable.app/** work. Then pass redirectTo explicitly on signUp and OAuth calls so the flow never falls back to the localhost default. Retest with a fresh signup; old confirmation emails carry the old link.

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

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

Related errors

The Vibe Oops briefing

One email when something ships to production that should not have. New incidents, new error guides, no filler.