Why does my app work in preview but not when published?
Last checked 31 Aug 2026
Short answer
Preview and the published site can differ due to environment variables, caching, or build-time settings that only apply to one environment. Check environment/secret configuration and hard-refresh the published URL before assuming it's a Lovable bug.
Common causes
- Environment variables/secrets set for preview but not carried through to production, or vice versa — see /questions/why-are-environment-variables-missing.
- Caching — the browser or a CDN is serving an old version of the published site. Hard-refresh (Ctrl/Cmd+Shift+R) or test in incognito.
- Different data — Preview might be using a different Supabase/Lovable Cloud project or dataset (e.g. test data) than what production points to.
- Build-only errors — some issues only surface during the production build step (stricter bundling, minification) and don't appear in Preview's dev-like environment.
- Domain/redirect differences — auth redirect URLs or CORS allow-lists configured for the preview domain but not the published (or custom) domain.
Diagnostic sequence
- Confirm you're actually testing the latest published version — republish if you're unsure, then hard-refresh.
- Open the browser console on the published site and compare any errors to what Preview shows (there should be none in Preview if it works there).
- Check whether the feature depends on a secret/API key — ask Lovable to confirm it's configured for production.
- If it involves login or an external API, check whether the published domain is included in the allowed redirect/origin list for that service.
What usually goes wrong
People assume "it's a Lovable bug" when it's actually a configuration difference between environments — most commonly a missing secret or an auth redirect URL that only lists the preview URL.
Fixing it
This works in Preview but fails when published. Console error on the published site: [paste]. Check whether any secrets, environment variables, or allowed URLs differ between preview and production.
For anything touching Stripe, OAuth, or email sending, double-check the production keys/URLs are genuinely production ones, not test/sandbox values left over from development.
Sources
Was this answer helpful?
Related questions
- AnswerWhy is Lovable chat stuck loading?Chat usually gets stuck loading due to a network blip, a very large/complex request, or a backend timeout. Refresh first, then check the console before resending the same prompt.
- AnswerHow do I fix a Lovable build error?Read the exact error message and file it points to, paste it back to Lovable, and let it fix that specific error rather than describing the symptom vaguely.
- AnswerWhy is my custom domain offline?Custom domains usually go offline because of a missing or changed DNS record, a certificate that hasn't issued yet, or the registrar's records pointing somewhere else — recheck the domain settings and your DNS provider.
- AnswerWhy am I getting "Failed to Fetch"?"Failed to fetch" means the browser couldn't complete a network request at all — usually CORS, a down endpoint, a missing/invalid API key, or no internet connection, rather than a code logic error.