Demo, all content is generated
Question

Google login in my Lovable app sends people to localhost:3000 after they pick their account

Solved · 2802 views · asked by mina_j · edited

Works in the Lovable preview. On my published app with custom domain: click Sign in with Google, choose account, and then the browser goes to

http://localhost:3000/#access_token=eyJ...

and shows 'site can't be reached'. Where does localhost:3000 even come from, I never typed that.

What I’ve tried

Searched my code for localhost, found nothing. Added my domain in Google Cloud Console to authorized origins.

Comment
Check the URL settings in Supabase Auth first, answer coming. amir_h · edited

3 answers

Marked as helpful by the asker
mira_dev · edited

localhost:3000 is Supabase's default Site URL. When the redirect you ask for isn't on the allow list, Supabase falls back to the Site URL.

Supabase dashboard → Authentication → URL Configuration:

  • Site URL: https://yourdomain.com
  • Redirect URLs: add https://yourdomain.com/**, and your lovable.app URL if you still use it (https://yourapp.lovable.app/**)

In Google Cloud Console the authorized redirect URI must be the Supabase callback (https://<ref>.supabase.co/auth/v1/callback), not your own domain. That part you probably already have since the preview works.

Comment
SITE URL WAS LOCALHOST. Fixed. Thank you so much mina_j · edited
Had this exact problem, same fix. Thanks noor_builds · edited
Still the most common Lovable auth issue I see with clients. pixelpaulo · edited
amir_h · edited

Also pass redirectTo explicitly in the code so you're not relying on the fallback:

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

That URL still has to match a Redirect URL entry.

Comment
jb_supa · edited

Late, but: if you still use the lovable.app preview, keep its URL in the Redirect URLs list too. Otherwise fixing prod breaks login in the preview.

Comment
oh that explains why the preview broke last week mina_j · edited