LeakPatrol › Guides

Supabase login or magic link redirects to localhost:3000 (fixed)

By LeakPatrol · Updated 20 November 2026

Your app is live, but a confirmation email, magic link, password reset or Google login sends people to http://localhost:3000 and they see "This site can't be reached". The app is fine. Supabase is following its own settings: when it doesn't accept the address your app asked for, it falls back to the project's Site URL, and the Site URL of a new project starts as http://localhost:3000. Supabase's Redirect URLs docs describe the setup.

Why it happens

The fix (two minutes)

  1. In Supabase, open Authentication → URL Configuration.
  2. Set Site URL to your live address, for example https://myapp.com.
  3. Under Redirect URLs, add the exact pages you redirect to in production, such as https://myapp.com/auth/callback. Keep http://localhost:3000/** only if you still develop locally.
  4. In your code, build the redirect from the current address instead of hardcoding it:
await supabase.auth.signInWithOtp({
  email,
  options: { emailRedirectTo: `${window.location.origin}/auth/callback` }
});

await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: { redirectTo: `${window.location.origin}/auth/callback` }
});

For Google or GitHub login, the provider's own console needs the Supabase callback (https://<project-ref>.supabase.co/auth/v1/callback), not your app's address. That part rarely changes.

The wildcard you should not add

Supabase allows wildcards in Redirect URLs: * matches one path segment and ** matches any path. They are handy for preview deployments, but the docs recommend exact paths for your production site. Avoid broad patterns that match addresses you don't control, such as a wildcard across every vercel.app or netlify.app subdomain. Login links carry tokens, and a redirect to someone else's site hands those tokens to them. Scope preview wildcards to your own team or project name.

A prompt to paste into Lovable, Bolt or Cursor

Supabase auth emails and Google login redirect to localhost:3000.
1. Find every emailRedirectTo and redirectTo in the code.
2. Replace hardcoded URLs with `${window.location.origin}/auth/callback`.
3. Make sure an /auth/callback route exists and finishes the login.
4. Tell me exactly which Site URL and Redirect URLs to set in
   Supabase under Authentication, URL Configuration.

While you're in the auth settings, check what your live site exposes. LeakPatrol's free read-only scan looks at your production JavaScript for secret keys and tests whether Supabase tables answer without a login. Related: "Database error saving new user" and "Invalid API key".

Check your app in a minute

Free, read-only, no sign-up. Every problem comes with a plain-English fix and a prompt for your AI tool.

Get the 10-point checklist

Every check we run on AI-built apps, with how to do each one yourself. Straight to your inbox.

Questions

Why does my Supabase magic link go to localhost:3000?

Supabase falls back to the project Site URL when your redirect is missing or not on the allow list, and the Site URL starts as http://localhost:3000. Set it to your live address under Authentication, URL Configuration.

Why is my redirectTo ignored by Supabase?

The exact address must be listed under Redirect URLs in Authentication, URL Configuration. If it is not, Supabase uses the Site URL instead.

Can I use wildcards in Supabase Redirect URLs?

Yes. A single star matches one path segment and a double star matches any path. Use them for local development and your own preview deployments, and exact paths for production.

I changed the settings but the email still opens localhost. Why?

Links in emails sent before the change keep the old address. Request a new email, and check the code does not hardcode localhost in emailRedirectTo.

More guides