Common errorsBlogHuman fixSponsor

Supabase email link redirects to localhost:3000

Last verified: October 18, 2026

Confirmation / magic link / password reset email redirects to http://localhost:3000

What it means

When no allowed redirect is used, Supabase sends users to the Site URL in Authentication → URL Configuration, and it starts out as http://localhost:3000. If your live or preview address isn't in the Redirect URLs list either, the email link can't send users back to your app.

How to fix it

  1. Open Authentication → URL Configuration.
  2. Set Site URL to your live address (e.g. https://yourapp.com).
  3. Add your preview and live addresses to Redirect URLs. Wildcards like https://*.lovable.app/** are fine for previews, but use exact URLs for production.
  4. If your code passes emailRedirectTo/redirectTo, make sure it uses the current site's address (window.location.origin), and that your email templates use {{ .RedirectTo }} where needed.

If your Lovable project uses Lovable Cloud instead of your own Supabase project, the same database lives under More → Cloud → Database. Its RLS view is read-only, so ask Lovable in chat (Plan mode) to make the policy change.

Stop the loop: paste these into Lovable

1. Diagnose first

Stop editing and don't retry earlier fixes. Supabase confirmation/magic-link/password-reset emails send users to http://localhost:3000 instead of my app. Without changing anything, show me every signUp, signInWithOtp, signInWithOAuth and resetPasswordForEmail call and whether it passes emailRedirectTo/redirectTo, and tell me what Site URL and Redirect URLs I should check in the Supabase dashboard. State the cause in one sentence and propose ONE minimal change.

2. Then the one fix

Make the redirect explicit: in each auth call that sends an email or starts OAuth, pass emailRedirectTo/redirectTo built from window.location.origin plus the callback path the app already uses. Change nothing else. Then list the exact Site URL and Redirect URLs entries I must add in Supabase → Authentication → URL Configuration for the live domain and preview domain. Tell me exactly what changed.

3. Save this rule so it stays fixed

Lovable: Project settings → Knowledge. Cursor: .cursor/rules or .cursorrules. Bolt: Project settings → Knowledge. Replit: replit.md.

Rule: Every Supabase auth call that sends an email or starts OAuth passes an explicit redirectTo/emailRedirectTo based on window.location.origin. The Supabase Site URL is the production domain, and every preview and live domain is listed in Redirect URLs.

FAQ

I fixed the Site URL but old emails still go to localhost.

Links in emails sent before the change keep the old address. Send a new email to test.

Why does it work in preview but not on my domain?

Your custom domain isn't in Redirect URLs, so Supabase falls back to the Site URL.

Sources

Your error is a bit different? Paste it with what you already tried and get a diagnose-first prompt, one fix and a rule for your exact case.

Break the loop — 3 free fixes Still stuck? Get a human fix