Production Ready
Works in preview, breaks when you publish
Your app worked in the builder. Now it's live and something broke. Here's why, and what to check first.
By Joe Minock · Last reviewed
It's almost always a setting that's different in the two places, not your code. The preview runs inside the builder, with its addresses and keys. The published app runs somewhere else, so anything that names an address or a key has to be set up again for it. Replit's own help page puts it plainly: "This is almost always a configuration difference between environments" (Replit's own help page).
Check these first
- Read the first red error Open your live site, open the browser's developer tools, and read the first red message in the Console. It usually names the problem: a blocked request, a missing key, or a page that wasn't found.
- Compare your keys List every key and setting the preview uses, then confirm each one is set where the live app runs.
- Add your live address to sign-in Your live address and any custom domain belong in your Supabase sign-in settings, and in Google's if you use Sign in with Google.
- Publish again After changing any setting, publish or deploy again so the live app picks it up.
- Switch to the live versions Payments, webhooks and automations each have a test version and a live version. The live app needs the live ones.
Find your symptom
- Sign-in sends people to localhost, or loops Supabase sends people to your Site URL after a sign-in email or password reset when the code names no other address, and its docs tell you to change it from localhost to your live address. Add your live address and custom domain to the allowed redirect addresses too. Wildcards can cover preview addresses (Supabase's redirect docs). On Lovable's built-in backend, a custom domain is added for you once it's active; with your own Supabase project, you set it yourself (Lovable's custom domain docs).
- Google says "redirect_uri_mismatch" The address Google sends people back to has to match one listed on your Google sign-in setup exactly (Google's docs). With Supabase in the middle, that's Supabase's own callback address, and your site goes under the allowed JavaScript addresses (Supabase's Google sign-in docs). While the app is still in Google's Testing status, only up to 100 people you've listed can sign in (Google's docs).
- "Blocked by CORS" The browser stopped a call to another address that didn't allow your site (MDN). A Supabase Edge Function called from the browser has to answer the browser's first check, and send the headers that allow your site (Supabase's CORS guide). For someone else's service, make the call from your server instead.
-
A blank page, or a key that's "undefined"
A setting exists in the builder but not where the app runs. Vite apps only put settings that start with
VITE_into browser code, and fix them when the app is built (Vite's docs); Next.js does the same withNEXT_PUBLIC_(Next.js). On Vercel and Netlify, a changed setting needs a new build. Replit keeps your editor's secrets and the published app's secrets separately, so set the key in the deployment's secrets and publish again (Replit's own help page). Supabase Edge Function secrets are set separately for testing and for live use (Supabase's docs). One warning: anything in aVITE_orNEXT_PUBLIC_setting can be read by anyone, so never put a secret key there. -
The home page works, other pages say "Page not found"
Your app handles its pages in the browser, but the host looks for a separate file for each address. Send every address to the app's main page: on Netlify, the rule
/* /index.html 200, which Bolt's own troubleshooting page gives for published Bolt sites; on Vercel, a rewrite to/index.html(Vercel's Vite docs). -
Payments work in testing, not live
Stripe's test and live modes have different keys: live ones start with
pk_live_andsk_live_(Stripe's docs). Live webhooks have to be set up on their own (go-live checklist), and each mode gets its own signing secret, even for the same address (Stripe's webhook docs). - The live app has none of your data On Replit, the published app gets its own production database, separate from the one you built with (Replit's docs). Check which database the live app is pointed at, and copy over what it needs.
- Your changes don't show up On Lovable, visitors see a snapshot that only changes when you publish (Lovable's docs). If you published and still see the old version, an app with a service worker can keep the old one until every tab using it is closed.
- Automations stop working In n8n, a webhook's test address only works while the editor is listening, for 120 seconds. The live app needs the production address, which works once the workflow is published (n8n's docs).
-
Calls work on your computer, fail live
Look for addresses written into the code, like
localhostor127.0.0.1; Replit's help page names these too (Replit's own help page). And a site on https can't call plain http addresses: browsers block those requests (MDN).
While you're in there
A missing key often leads to a key in the wrong place. Before you launch, run our ten-point security checklist: data rules on every table, no secret keys in the browser, and logins checked on the server.
Still stuck?
If it's more than a setting, start with our Production Ready review: a senior read of your app, delivered within a week, with what's broken, why, and what to fix first.
Common Questions
Frequently asked questions
Why does my Lovable app work in preview but not when I publish it?
Almost always because a setting is different in the two places, not because the code is wrong. The preview runs inside the builder with its own addresses and keys. The published app is a snapshot that runs somewhere else, so every sign-in address, key and outside service has to be set up for it too. Changes in the editor don't reach visitors until you publish again.
Why does sign-in send me back to localhost after I publish?
Your Supabase Site URL still points at localhost. Supabase sends people there after a sign-in email or password reset when the code doesn't name another address. Change it to your live address, and add your live address and custom domain to the allowed redirect addresses.
What does "blocked by CORS" mean?
The browser stopped your page from calling another address, because that address didn't say your site was allowed. If it's your own Supabase Edge Function, add the CORS answer Supabase's guide shows. If it's someone else's service, call it from your server or an edge function instead, which also keeps its key out of the browser.
Do I have to publish again after I change a setting?
Usually, yes. On Vercel, Netlify and Replit, a changed key or variable only reaches the live app with a new build or a new publish. With Vite and Next.js, the values used in browser code are fixed when the app is built.
Proof
How we built Deliberate with Claude Code
Deliberate is our own Mac app, built by a three-person team with Claude Code. We built the app, its registration and billing site, and integrations with Gmail, Outlook, Slack, Asana, Zoom and Granola. It runs on your Mac, never saves the full text of your email, and sends nothing without your yes.
Meet DeliberateStill broken after publishing?
Send us the link and the first error you see. We'll tell you what we'd check first.