aiRepoFix / How-to fixes

Lovable + Supabase login redirects to localhost (or loops) after publishing: how to fix it

Last checked against vendor documentation: October 17, 2026.

Short answer: the usual cause is that your Supabase project's Site URL and Redirect URLs still point at localhost or the preview address, not your live domain. Add the live address in Supabase under Authentication > URL Configuration, check the redirectTo value in your code, and test again in a private window. On Lovable's built-in backend (Cloud) there is no Supabase dashboard to open: ask Lovable in the project chat to add your domain to the auth redirect URLs, or use Auth settings > Advanced (see below).

Symptoms this page covers

Cause 1: the Site URL and Redirect URLs are wrong

Supabase Auth only sends people back to addresses you have allowed. Two settings matter:

Lovable's own docs say the same thing from their side: if sign-in works in preview but breaks on your published app or custom domain, these URLs are usually the reason. How much Lovable does for you depends on your backend:

If you use Lovable's built-in backend (Cloud)

Lovable's docs say that for apps on the built-in backend, Lovable keeps the Site URL and Redirect URLs up to date for you when you publish and when you connect a custom domain. If sign-in still fails on your published app or custom domain, the address is probably missing from the list. Lovable gives two ways to fix it:

  1. Ask Lovable in the project chat to add your domain to the auth redirect URLs. For example: "Add https://yourdomain.com and https://www.yourdomain.com to the auth redirect URLs."
  2. Or add it yourself: open More > Cloud > Users > Auth settings, then Advanced > Redirect URLs. Lovable says this list holds up to 50 URLs, and that the Site URL (the default address used when none is given) is in the same Advanced section.

Menu names change, so if yours differ, ask Lovable in the chat where the setting is. Lovable says a Site URL you set yourself stays as you set it, so check that it isn't still a preview or localhost address. We have not tested these steps in a live Lovable project; they come from Lovable's documentation.

Fix, step by step (your own Supabase project)

  1. Open your project in the Supabase dashboard and go to Authentication > URL Configuration. (Menu names change now and then. Supabase's Redirect URLs guide describes this page as the URL Configuration page.)
  2. Set Site URL to your live address, for example https://yourdomain.com.
  3. Under Redirect URLs, add the live address you use for sign-in, with the exact path your app returns to, for example https://yourdomain.com/ and any callback or dashboard path you pass as redirectTo.
  4. Add the www version separately if people can reach it, for example https://www.yourdomain.com/. The two are different addresses. Supabase's wildcard * does not match across . or /, so don't count on a wildcard to cover it.
  5. Keep http://localhost:3000/** only if you still develop locally. Supabase recommends exact paths for production rather than the broad ** pattern.
  6. Save, then test (see below).

If you use Google or another provider with your own credentials, the new domain may also need a redirect URI in that provider's console (for Google, Google Cloud Console). Lovable's authentication docs mention this.

Cause 2: the redirectTo value in your code

Look for redirectTo (used with signInWithOAuth) or emailRedirectTo (used with signUp and signInWithOtp email magic links) in your code. Common problems:

const { data, error } = await supabase.auth.signUp({
  email,
  password,
  options: {
    emailRedirectTo: 'https://yourdomain.com/welcome'
  }
})

Using window.location.origin instead of a hard-coded address works on any domain, but every domain you use then has to be in the Redirect URLs list.

If it still loops after the settings are right

Once the URLs are correct, a loop usually comes from the code: a check that decides "not signed in" and redirects to the sign-in page before the sign-in has finished loading. Supabase's onAuthStateChange reports an INITIAL_SESSION event for exactly this; wait for it before redirecting anyone. For an example of how we explain this kind of fix, see the labeled-as-illustrative example on our homepage (it is a made-up example, not a customer).

How to test

  1. Open your live domain in a private (incognito) window so no old session interferes.
  2. Sign up or sign in with a test account. For email links, open the link from the email and check the address bar: it should be your live domain, not localhost.
  3. You should land on your dashboard, and still be signed in after a refresh.

What you can do yourself, and when it is a code change. The Supabase URL settings above are dashboard settings: you change them yourself, and we can't access your Supabase dashboard. If the cause is in your code (a hard-coded localhost address, the redirect check running too early), that is a change in your repo, and we deliver it as a pull request. We tell you in the pull request notes if part of the fix is a dashboard setting for you to change.

Sources

This page is based on the vendor documentation below. Menu names and defaults change, so check the source if something on your screen looks different.

Last checked: October 17, 2026. aiRepoFix is not affiliated with or endorsed by the companies named on this page.

Still stuck? Describe it free.

Tell us what is broken. We review it and either email you the flat price for the tier that fits ($49 Quick, $99 Standard, $149 Full) with a payment link, or tell you we can't take it, and you pay nothing. The fix comes as a pull request you review, and nothing in your app changes until you merge it. Pull request delivered within 96 hours of a complete order (weekends and US holidays don't count), or 20% back. (conditions apply)

Please don't send passwords, API keys or .env files. We don't need them.

aiRepoFix is an independent service that fixes bugs in the code in your own GitHub repository and delivers a pull request; it is not technical support for Lovable, Supabase, Cursor, Bolt, Replit or any other platform mentioned on this page.

Still stuck? Describe it free →