Skip to content

Guides · VibeVigil

Why Does My Supabase Login Link Go to localhost? How to Set Site URL and Redirect URLs Safely

Your confirm-email, magic link or password reset link opens localhost:3000, or sign-in works in preview but not on your real site. Here's why (the Site URL and the Redirect URLs list), how to fix it in Supabase or Lovable Cloud, and how to avoid wildcard redirect rules that let login links land on someone else's website.

Not sure your app is safe? Run a free scan first.
VibeVigil checks your live web app for exposed keys, Supabase tables a stranger can read, missing security headers, SSL problems and downtime. Every issue comes with a ready-to-paste prompt for your coding agent.
Scan my app for free → (only scan apps you own)

Note: the scan does not read your auth settings. Use the steps below to check your Site URL and Redirect URLs yourself.

Why Does My Supabase Login Link Go to localhost?

You launched your app. A new user signs up, clicks "Confirm your email", and lands on localhost:3000. Or the password reset link opens a page that does not exist. Or Google sign-in works in preview but fails on your real domain.

These are all the same problem: two settings in your auth project, the Site URL and the Redirect URLs list. This guide shows how to fix them. It also shows how to set them safely, because the Redirect URLs list is a security setting, not just a convenience.

The short answer

  1. The Site URL is the default place users go after they click a link in an auth email. Supabase says it "defaults to localhost:3000" until you change it (Supabase: Password-based Auth). Change it to your real address, like https://yourapp.com.
  2. The Redirect URLs list is an allow list. When your code asks Supabase to send a user somewhere after login (the redirectTo option), that address "should match the Redirect URLs list" (Supabase: Redirect URLs). Add your real domain there.
  3. Keep wildcards tight. A rule like https://*.vercel.app/** matches every app on vercel.app, not just yours. Use your own domain, or a pattern that includes your team name.
  4. Remove old test addresses you don't use anymore.

Why this happens

When someone signs up, asks for a magic link, or resets a password, Supabase sends an email. The link in that email goes to Supabase first, then sends the person back to your app, signed in.

"Back to your app" means one of two places:

  • The address your code asked for (redirectTo), if it is on your allow list.
  • The Site URL, if your code did not ask for one. Supabase calls this "the default redirect URL when no redirectTo is specified" and says it "is critical for email confirmations and password resets" (Supabase: Redirect URLs).

So if you built your app on your laptop and never changed the Site URL, your users get sent to localhost:3000. That is your laptop's address, so for everyone else the page will not load.

If your email templates were edited, also check them. When you use redirectTo, Supabase says you may need to use {{ .RedirectTo }} instead of {{ .SiteURL }} in your email templates (Supabase: Redirect URLs).

How to fix it

Your own Supabase project

  1. Open your project in the Supabase dashboard.
  2. Go to Authentication → URL Configuration.
  3. Set Site URL to your live address, for example https://yourapp.com.
  4. Under Redirect URLs, add the exact addresses your app sends people back to, for example https://yourapp.com/** (all pages on your site).
  5. Ask for a new confirmation or reset email and click it. Old emails still have the old link.

Lovable Cloud (built-in backend)

Lovable keeps these settings under More → Users → Settings → Advanced. Lovable says:

  • Site URL is "the default URL users are redirected to after authentication when no redirect URL is specified."
  • Redirect URLs holds up to 50 addresses "that auth providers are permitted to redirect to after authentication."
  • When you publish, Lovable sets the Site URL to your published address (unless it is already on your own domain), and when you connect a custom domain, Lovable adds it to the Redirect URLs.

If sign-in works in preview but not on your published app, Lovable says the published URL or custom domain is usually missing from the Redirect URLs list. You can add it on that screen or ask Lovable in the project chat to add it. If you use Google sign-in with your own Google credentials, also add the new address in Google Cloud Console (Lovable: Users and authentication).

Two Lovable details worth knowing (Lovable: Users and authentication):

  • Lovable rejects localhost addresses. To test on your computer, use something like http://127.0.0.1:5173/**.
  • Each time Lovable updates the list, it removes other addresses on Lovable domains, such as another lovable.app address. Use a domain you own for anything outside your project.

The security part: keep your allow list tight

The Redirect URLs list decides which websites are allowed to receive a user right after they log in. Depending on how your app's login works, the link that lands there can carry the user's login code or tokens. That is why the list exists: so a login link can only send people to places you trust.

Wildcards make this list easier to manage, but they can open it too wide. Here is how Supabase's patterns work (Supabase: Redirect URLs):

PatternWhat it matches
*Any text that has no . or / in it
**Any text at all, including . and /
?One character that is not . or /

Now look at what some common rules really allow:

Rule in your listWho it lets in
https://yourapp.com/**✅ Any page on your own domain
https://*-yourteam.vercel.app/**✅ Preview links for your Vercel team (this is the pattern Supabase shows, with your team or account name)
https://*.vercel.app/**❌ Any app on vercel.app, including apps made by strangers
https://*.netlify.app/**❌ Any app on netlify.app
https://** or **❌ Any website on the internet

Anyone can put an app on vercel.app or netlify.app for free. So a rule like https://*.vercel.app/** trusts websites you don't control.

Supabase's own advice: "While the 'globstar' (**) is useful for local development and preview URLs, we recommend setting the exact redirect URL path for your site URL in production" (Supabase: Redirect URLs).

Simple rules to follow:

  • Use your own domain in production: https://yourapp.com/**.
  • For Vercel previews, include your team or account name, as Supabase shows: https://*-<team-or-account-slug>.vercel.app/**.
  • For Netlify previews, include your site or team name, as Supabase shows: https://**--my_org.netlify.app/** (with your own name).
  • Delete old addresses: test domains you gave up, old Lovable or Bolt preview links, a friend's laptop address.
  • Never add a rule that is only a wildcard.

Check your own app's "next" link too

Many apps add a ?next=/dashboard part to login links, so the user lands on the right page after login. If your code sends the user to whatever next says, someone could put another website's address there. This is called an "open redirect." OWASP warns that open redirects can be used in phishing, because the link starts with your real domain (OWASP: Unvalidated Redirects and Forwards Cheat Sheet).

The fix is small: only accept a path on your own site (like /dashboard), not a full address. Supabase's own example code does this by putting next into the path of your own URL (Supabase: Password-based Auth).

Quick test: open https://yourapp.com/auth/confirm?next=https://example.com (use your real callback path). If you end up on example.com, ask your coding agent to fix it.

Prompt for your coding agent

Copy this into Lovable, Bolt, Cursor or Claude Code:

Please check and fix my Supabase auth redirect setup.

1. Find every place the app passes redirectTo / emailRedirectTo (signUp, signInWithOtp, signInWithOAuth, resetPasswordForEmail). List the addresses it uses. Production should use my live domain, not localhost or a preview address.
2. Tell me what my Site URL should be and which exact Redirect URLs I need. I will set them in Supabase (Authentication > URL Configuration) or Lovable (More > Users > Settings > Advanced). Do not suggest broad wildcards like https://*.vercel.app/** or https://*.netlify.app/**. For previews, use a pattern that includes my team or account name.
3. If my email templates were customized, check whether they should use {{ .RedirectTo }} instead of {{ .SiteURL }}.
4. Find any login, callback or logout route that redirects to a "next", "redirect" or "returnTo" value from the URL. Make it accept only a relative path on my own site (starting with a single "/"), and fall back to "/" for anything else.
5. Give me a short test plan: sign up with a new email, reset a password, try a magic link, and open my callback route with next=https://example.com to confirm it stays on my site.

Do not turn off email confirmation and do not put the service role key in the browser.

Quick checklist

  • [ ] Site URL is your live address, not localhost:3000
  • [ ] Redirect URLs include your live domain (and custom domain, if you have one)
  • [ ] No rule like https://*.vercel.app/**, https://*.netlify.app/** or **
  • [ ] Old test and preview addresses are removed
  • [ ] Email templates use {{ .RedirectTo }} if your code uses redirectTo
  • [ ] Your callback route only follows next values that are paths on your own site
  • [ ] You tested sign-up, password reset and (if used) Google sign-in on the live site

Related guides

Sources

  • Supabase docs, Redirect URLs: https://supabase.com/docs/guides/auth/redirect-urls
  • Supabase docs, Password-based Auth: https://supabase.com/docs/guides/auth/passwords
  • Lovable docs, Users and authentication: https://docs.lovable.dev/features/authentication
  • OWASP, Unvalidated Redirects and Forwards Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html

Want a check on the public side of your app? VibeVigil looks for exposed keys, open Supabase tables, headers, SSL and uptime, and gives you a fix prompt for each issue. Run a free scan → (only scan apps you own)

Scan your app free. It checks the public page of a site you own. No account.

Why Does My Supabase Login Link Go to localhost? How to Set Site URL and Redirect URLs Safely · VibeVigil