Works in preview, broken in production: the 7 usual suspects
Your Lovable, Bolt or Cursor app runs perfectly in the editor but the published site breaks. A plain-English checklist of the differences between preview and live.
Building a new app instead? Try Bolt (20% off with our link) (affiliate link).
Why it happens
Preview and production are different environments. The live site has its own domain, its own build, its own environment variables, and sometimes a different database, so anything tied to the preview setup can break.
The most common differences: missing environment variables, Supabase auth redirect URLs that do not include the live domain, CORS rules or API keys locked to the preview domain, Stripe test keys vs live keys, and single-page-app routes returning 404.
Production builds are also stricter and cached: old JavaScript can stick around in browsers, and errors hidden in preview may stop the build.
How to fix it, step by step
- Open the live site with the browser console open (F12). Write down the first red error.
- Environment variables: confirm every variable exists in your host's settings with the right prefix (VITE_ or NEXT_PUBLIC_), then redeploy.
- Auth: add the live domain to Supabase → Authentication → URL Configuration (Site URL and Redirect URLs).
- Domains: add the live domain anywhere a preview domain is allowed, such as CORS lists in Edge Functions, Google OAuth origins, and API key restrictions.
- Payments: make sure live mode uses live Stripe keys, live prices and a live webhook endpoint.
- Routing: if refresh gives 404, add the single-page-app rewrite for your host.
- Hard-refresh (Ctrl/Cmd+Shift+R) or test in a private window to rule out cached files.
Paste-ready prompt for Lovable
My app works in preview but breaks on the live domain <your domain>. The first console error is: <paste error> Please check, in order: environment variables and prefixes, Supabase auth redirect URLs, CORS / allowed origins, Stripe test vs live keys, SPA rewrites for refresh 404s. Tell me which one is the cause, fix only that, and list any dashboard settings I need to change myself.
FAQ
Which should I check first?
Start with the first red error in the browser console on the live site; it usually points straight to one of these.
Could it be my custom domain?
Yes. If only the custom domain is broken, look at DNS/SSL and any allow lists that still name the old domain.
Still broken?
Get a free diagnosis by email within 24 hours. Fixed or refunded.
Get a free diagnosisOr get the weekly fix digest:
Free: the Vibe-Code Fix Checklist.