December 3, 2026 · Eric, Mijnwebsiteonline

Supabase auth emails link to localhost? Fix your redirect URLs

When a Lovable, Bolt or Cursor app on Supabase sends magic links or reset emails that open localhost:3000, the Site URL and the Redirect URLs allow list are still on dev defaults. Here is the ten-minute fix.

There's no news in our lane today, so here is a fix for one of the most common launch bugs we see in Lovable, Bolt, Replit and Cursor apps on Supabase. Sign-up works on your machine. You deploy, a real user asks for a magic link or a password reset, and the link in their inbox opens http://localhost:3000. On their machine, that's nothing.

The cause is almost always one dashboard setting that never left its development value. The fix takes about ten minutes, and you can do it without a redeploy for the dashboard part.

Why the link points at localhost

Supabase Auth builds every email link from two settings. The Site URL is, in Supabase's words, the "default redirect URL when no redirectTo is specified in the code". The Redirect URLs list is an allow list: any URL your code passes as redirectTo or emailRedirectTo should match an entry in it. Supabase's own docs tell you to change the Site URL "from http://localhost:3000 to your production URL", and that step is easy to miss when an AI builder wired up auth for you while you were still on localhost.

So two things go wrong. Either the code passes no redirect at all and Supabase falls back to the localhost Site URL, or the code passes a production URL that isn't on the allow list.

The fix, step by step

  1. Set the Site URL. In the Supabase dashboard, open your project, then Authentication, then URL Configuration. Set Site URL to your production origin, such as https://app.example.com.
  2. Fill the allow list. Under Redirect URLs, add the exact callback paths your app uses in production, for example https://app.example.com/auth/callback. Supabase recommends exact paths in production.
  3. Add dev and preview patterns. For local work, add http://localhost:3000/**. On Vercel, the docs suggest a pattern like https://*-your-team-slug.vercel.app/** for preview deploys. Netlify previews follow the same idea with their own subdomain format. Remember that * stops at . and /, while ** matches anything.
  4. Pass the redirect in code. Search your codebase for the auth calls and make the target explicit: emailRedirectTo in the options of signInWithOtp and signUp, redirectTo in the options of signInWithOAuth, and redirectTo in resetPasswordForEmail(email, { redirectTo }), where the options object is the second argument rather than nested under options. Build that URL from an environment variable such as NEXT_PUBLIC_SITE_URL, set to your production origin, rather than a hard-coded string. A generated app often has http://localhost:3000 written straight into one of these calls.
  5. Check the email templates. Under Authentication, look at the confirm, magic link and reset templates. Supabase's docs note that when you use redirectTo, you may need to replace {{ .SiteURL }} with {{ .RedirectTo }}, otherwise the link ignores the target you passed.
  6. Test from a real inbox. Deploy, then request a magic link and a password reset for an address you can read, from a private window on the production domain. Click both links. Then do the same from a preview deploy if you use them.

What this doesn't fix

If the link now opens the right domain but the user lands logged out, the problem has moved further down: a missing callback route that exchanges the code for a session, cookies set on the wrong domain, or middleware that redirects before the session exists. That's the territory of our logins that drop or leak page. And if the whole app behaves differently once deployed, start with environment variables, because the same localhost value often hides in more than one place.

Quick answers

Why does my Supabase magic link open localhost:3000?

The Site URL in your Supabase project is still http://localhost:3000. Supabase uses it as the default redirect when your code passes no redirectTo, so confirm, magic link and reset emails all point at your laptop. Set it to your production URL.

Where do I change the Supabase Site URL and Redirect URLs?

In the Supabase dashboard, open your project, then Authentication and URL Configuration. The Site URL is the default target, and the Redirect URLs list is the allow list for any redirectTo or emailRedirectTo your code passes.

Should I use wildcards in Supabase Redirect URLs?

For local development and preview deploys, yes, such as http://localhost:3000/** or your Vercel preview pattern. For production, Supabase recommends the exact redirect URL path rather than a wildcard.

Do I need to change my Supabase email templates when I use redirectTo?

Possibly. Supabase's docs say that with a redirectTo option you may need to replace {{ .SiteURL }} with {{ .RedirectTo }} in the email templates, or the link keeps using the Site URL.

Is your app affected? Get a $199 audit

Not sure whether this touches your app? That is exactly what the audit answers.

  • A recorded video walkthrough of your app, by the person who would fix it
  • Written findings: what is broken or exposed, and why
  • A fixed price for the fix, before any work starts
Book my $199 audit

Book my audit

$199. Fixed price, agreed up front.

Ask a question first

No payment and no obligation, just an answer.