<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Harjot Singh Rana]]></title><description><![CDATA[Harjot Singh Rana]]></description><link>https://harjotrana.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 02 Nov 2026 15:59:27 GMT</lastBuildDate><atom:link href="https://harjotrana.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Supabase login works locally but fails in production]]></title><description><![CDATA[Sign-in works on your machine or in the builder's preview. On the live domain it sends people back to the sign-in page, the email link opens localhost, or…]]></description><link>https://harjotrana.hashnode.dev/supabase-login-works-locally-but-fails-in-production</link><guid isPermaLink="true">https://harjotrana.hashnode.dev/supabase-login-works-locally-but-fails-in-production</guid><category><![CDATA[supabase auth]]></category><dc:creator><![CDATA[Harjot Singh Rana]]></dc:creator><pubDate>Fri, 16 Oct 2026 10:41:23 GMT</pubDate><content:encoded><![CDATA[<p>Sign-in works on your machine or in the builder's preview. On the live domain it sends people back to the sign-in page, the email link opens localhost, or Google sign-in shows an error.</p>
<p>The code is usually fine. Supabase and Google tie a few settings to one web address, and those settings still point at the old one. Check these five in order. Each takes a few minutes in a dashboard, no code.</p>
<h2>1. Site URL and redirect URLs in Supabase</h2>
<p>Open Supabase, then Authentication, then URL Configuration. The Site URL is where confirmation and magic-link emails send people by default. If it still says <a href="http://localhost:3000">http://localhost:3000</a> or the preview address, every email link goes there.</p>
<p>Set the Site URL to your live domain, for example <a href="https://yourapp.com">https://yourapp.com</a>. Under Redirect URLs, add every address people sign in from: the live domain, the www version and the preview address. A wildcard like <a href="https://yourapp.com/">https://yourapp.com/</a>** covers the inner pages.</p>
<p>On Lovable, the preview runs on a lovable.app address. Once you connect your own domain, add it here too.</p>
<p>Signs: The link in the email opens localhost or the preview. After sign-in you land on the home page instead of where you started.</p>
<h2>2. Environment variables on the live host</h2>
<p>The live site needs the same Supabase URL and anon (public) key as the preview. The builder keeps them for its own preview, but Vercel or Netlify only have what you added there.</p>
<p>The names depend on the app. Vite apps (Lovable, Bolt) use VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY. Next.js apps use NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY. These values are baked in when the site builds, so redeploy after you add or change them.</p>
<p>Check that both point at the project you test against. A live site wired to a second, empty Supabase project looks like a login bug: the users you created don't exist there.</p>
<p>Signs: The browser console shows "supabaseUrl is required" or "Invalid API key", or requests go to an address with "undefined" in it.</p>
<h2>3. Google or GitHub sign-in settings</h2>
<p>In Google Cloud, open your OAuth client. The authorized redirect URI must be the Supabase callback, <code>https://&lt;project-ref&gt;.supabase.co/auth/v1/callback</code>, and your live domain belongs under authorized JavaScript origins.</p>
<p>In Supabase, open Authentication, then Sign In / Providers, and check Google is switched on with the client ID and secret from that same OAuth client. A provider that is off, or holds keys from a different client, fails only for that sign-in button.</p>
<p>Then open the OAuth consent screen. While its publishing status is Testing, only the test users you listed can sign in, so it works for you and fails for everyone else. Publish the app to move it to production.</p>
<p>GitHub sign-in works the same way: the callback URL in the GitHub OAuth app must be the Supabase callback.</p>
<p>Signs: Google shows redirect_uri_mismatch or "Access blocked". Sign-in works for you and nobody else.</p>
<h2>4. Email delivery</h2>
<p>Supabase's built-in email sender is meant for trying things out. It only sends to the email addresses of your Supabase team members and allows very few emails an hour. Real users never get the confirmation or password reset email.</p>
<p>Set up your own SMTP sender (Resend, Postmark, Amazon SES or similar) under Authentication, then Emails, then SMTP settings. Then send yourself a reset email from a new address to check it arrives.</p>
<p>Signs: You get the emails and your users don't, or sign-up fails with "email rate limit exceeded".</p>
<h2>5. Sessions that drop on refresh</h2>
<p>In a Next.js app on @supabase/ssr, the session lives in cookies and the middleware has to refresh it on each request. If the middleware file is missing, or its matcher skips the pages people use, users look logged out after a refresh or on server-rendered pages.</p>
<p>In a Vite app, a refresh on an inner page like /dashboard that shows a 404 is a hosting problem, not a login one: the host needs a rewrite that sends every path to index.html.</p>
<p>Signs: Logged in, then logged out after a refresh. Server pages treat a signed-in user as a guest.</p>
<h2>Test it like a new user</h2>
<ol>
<li>Open the live site in a private window.</li>
<li>Sign up with an email address you have never used on the app.</li>
<li>Confirm from the email and check the link opens the live domain.</li>
<li>Refresh a logged-in page, then sign out and sign back in.</li>
<li>If you have Google sign-in, try it from a Google account that isn't yours.</li>
</ol>
<h2>Still stuck?</h2>
<p>Still failing after all five? I find the cause for you. The $149 diagnosis gets you a video of the bug on your live site and a plain-English fix plan within 48h of access. No passwords: you add me to your tools, and during the diagnosis I only look. Request one at <a href="https://fixedlaunch.com/">https://fixedlaunch.com/</a>.</p>
<p><a href="https://fixedlaunch.com/guides/supabase-login-works-locally-fails-in-production">Originally published on fixedlaunch.com.</a></p>
]]></content:encoded></item></channel></rss>