Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

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

  1. Confirm you're actually testing the latest published version — republish if you're unsure, then hard-refresh.
  2. 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).
  3. Check whether the feature depends on a secret/API key — ask Lovable to confirm it's configured for production.
  4. 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

Website made, maintained and hosted by PromptSites.com

PromptSites logo