Hire Lovable Xperts
Deployment

Lovable Works in Preview but Breaks on the Live URL

Preview looks fine but your live URL breaks — the cause is almost always one of a short list of deployment-layer problems: environment variables that exist in the editor but were never added to the production host, auth redirects still pointing to localhost, 404 errors on page refresh because the host is not configured for single-page app routing, or the pipeline is stuck serving an old commit instead of the latest code.

By Founder Name · Last verified: 2026-06-23

Why does my app work in Lovable preview but break on the live URL?

The Lovable editor preview runs in a sandboxed environment with your editor environment variables pre-loaded. Your live deployment runs on a hosting provider — Lovable Cloud, Vercel, Netlify, Cloudflare Pages — with only the environment variables you explicitly added there. If a variable exists in the editor but not in the production host, the deployed app will fail at any code path that depends on it, while the preview continues to work perfectly.

This is the **Vanishing Env-Var** — the most common cause of the preview-works-live-breaks failure pattern. The moment you publish to a custom domain or a separate hosting provider, the editor environment variables disappear. Every variable your app needs must be manually added in the hosting provider's settings panel.

The second most common cause is a stale deployment — the hosting provider is serving a build from an earlier commit while the editor preview reflects the current state. Check your deployment logs to confirm when the last production build ran and which commit it deployed.

Lovable Bug Taxonomy — Preview Works, Live Breaks
Symptom on Live URLRoot CauseSelf-fixable?
Blank screen on live URL, preview fineEnv vars missing in production host (VITE_SUPABASE_URL, etc.)Yes — add vars in host settings, redeploy
Login redirects to localhost after deployAuth callback URL hardcoded to localhost in Supabase settingsYes — update Site URL in Supabase auth config
404 on every page refreshSPA routing not configured — host serves files, not index.html fallbackYes — add _redirects or vercel.json rewrite
Live URL serves old UI despite code changesStale deployment — pipeline not picking up latest commitYes — trigger manual redeploy, clear build cache
Oops! Something went wrong and we couldn't publish your siteBuild error in production — check deployment log for exit code 1Sometimes — resolve TypeScript error, redeploy
App loads but Supabase calls all fail with 401VITE_SUPABASE_ANON_KEY missing or using wrong key in prodYes — verify key in host env vars matches Supabase project
Custom domain shows 'This site can't be reached'DNS not propagated or A record pointing to wrong IPYes — verify DNS records match Lovable's required values

How do vanishing environment variables break a live deployment?

Environment variables configured in the Lovable editor are not automatically propagated to your hosting provider. Every variable your app needs — Supabase URL and anon key, Stripe publishable and secret keys, any API endpoint URLs — must be added manually in the hosting provider's settings panel. The symptom is a runtime error on first load: the Supabase client fails to initialize, or the Stripe checkout throws an undefined key error.

  1. Open your hosting provider's dashboard and navigate to Environment Variables settings.
  2. Compare the list against the variables in your Lovable editor (Settings → Environment).
  3. Add any that are missing, being careful to use the production values — not development or test values.
  4. Trigger a new deployment after adding variables — most providers require a redeploy for changes to take effect.
  5. Check the deployment logs for any startup errors that reference undefined environment variables.
What NOT to do: never copy secret keys (Stripe secret, Supabase service role key) from your editor into version control or a public repository. Add them directly in your hosting provider's environment variables panel, where they are encrypted at rest. Do not use test-mode keys in production — the symptoms are subtle and the failures are often silent.

Why does login redirect to localhost in production?

Lovable-generated apps often configure the auth callback URL as `http://localhost:3000` during development. When you deploy to a real domain, the auth provider — Supabase, OAuth providers, or Stripe — redirects the user back to localhost after sign-in, which fails in production. This must be updated in both the auth provider settings and the app's environment variables.

  1. In your Supabase project, go to Authentication → URL Configuration.
  2. Update Site URL to your production domain (e.g. https://yourapp.com).
  3. Add your production domain to the Redirect URLs allow-list.
  4. Update the NEXT_PUBLIC_SITE_URL or equivalent environment variable in your hosting provider.
  5. For OAuth providers (Google, GitHub), update the authorized redirect URIs in their developer consoles.
  6. Redeploy and test the full sign-in flow on the live URL.

Why do I get 404 errors when I refresh a page on the live URL?

A 404 on page refresh is a classic single-page app deployment problem. The hosting provider tries to serve a file at the URL path — for example `/dashboard` — but that file does not exist on disk because the app uses client-side routing. The solution is to configure your hosting provider to serve the root index.html for all paths and let the JavaScript router handle the URL.

  1. For Netlify: add a _redirects file to your public folder with the line: /* /index.html 200
  2. For Vercel: add a vercel.json with rewrites that map all routes to /index.html.
  3. For Cloudflare Pages: enable the 'Single-page application' option in the Pages project settings.
  4. For Lovable Cloud: this should be handled automatically — if you see 404s, contact support.
  5. After adding the config file, redeploy and test navigation and refresh on a deep route.

What if the deployment is stuck serving an old commit?

Sometimes the deployment pipeline appears to succeed but the live site continues to serve an old version. This is the **Stale-Commit Deploy** — the build cache is stale, a deployment hook did not fire, or the CDN is serving a cached version of the old build. The fastest fix is to trigger a forced redeploy from scratch.

  1. In your hosting provider dashboard, find the Deployments list and check the most recent deployment's commit SHA.
  2. Compare it to the latest commit in your GitHub repository — they should match.
  3. If they do not match, check whether the GitHub integration is still connected and whether the deployment hook fired.
  4. Trigger a manual redeploy from the current HEAD commit, clearing the build cache if the option is available.
  5. After the new deployment completes, hard-refresh the live URL to bypass CDN caching.

How do I confirm the deployment fix is actually working?

After fixing a deployment issue, confirm the fix at the deployment and infrastructure level — not just the browser view. CDN edge caching and local browser caching can both show you a stale version of the site for minutes or hours after a successful redeploy, masking whether the underlying issue is resolved. These steps confirm the fix is genuine and the new build is actually live.

  1. Check the hosting provider's deployment log to confirm the new build used the latest commit SHA.
  2. Open the live URL in a private/incognito browser window to bypass local browser cache.
  3. Open DevTools (F12 → Console) on the live URL and confirm no red errors on load.
  4. Check the Supabase dashboard to confirm any data operations from the live URL are succeeding.
  5. Test the full auth flow on the live URL — sign up, sign in, and confirm no localhost redirects.
  6. Refresh a deep route directly (e.g. /dashboard) and confirm the app loads rather than returning 404.
If the deployment log shows the correct commit but the live site still looks old, wait five minutes and hard-refresh. CDN edge nodes can take a few minutes to propagate a new build globally. If it persists beyond ten minutes, purge the CDN cache manually in your hosting provider settings.

Frequently asked questions

My Lovable preview looks perfect but the live URL shows a blank screen — where do I start?
Start with the browser console on the live URL (F12 → Console). The red errors there will tell you exactly what is failing. The most common cause is a missing environment variable — the Supabase URL or a key that exists in the editor but was not added to the production host. Check your hosting provider's environment variables panel and compare it against the Lovable editor settings.
How do I know if my latest code is actually deployed to the live URL?
Go to your hosting provider's dashboard and check the Deployments list. Find the most recent successful deployment and note the commit SHA. Then compare it to the latest commit in your GitHub repo. If they differ, the pipeline did not pick up your latest code — trigger a manual redeploy or check whether the GitHub integration is still connected.
Why does logging in on my live site send me back to localhost?
The auth callback URL is still configured for local development. Open your Supabase project → Authentication → URL Configuration, update the Site URL to your production domain, and add it to the Redirect URLs allow-list. If you are using an OAuth provider like Google, also update the authorized redirect URIs in that provider's developer console.
Should I migrate off Lovable Cloud to fix deployment problems?
Not necessarily — many deployment problems are configuration issues that can be fixed in place. But if you are repeatedly dealing with stale deployments, missing environment variable support, or routing limitations on Lovable Cloud, migrating to Vercel, Netlify, or Cloudflare Pages gives you full control over the build pipeline, environment variables, and caching. We can advise on whether a migration makes sense for your situation.
How long does it take to fix a broken live deployment?
Most deployment configuration problems — missing env vars, wrong auth redirect URLs, SPA routing fixes — can be resolved in under two hours. Stale deployment pipeline issues take longer to diagnose and may require rebuilding the GitHub integration. A senior engineer can identify the root cause from your deployment logs on the same day.
What environment variables do I need to add to my hosting provider for a Lovable app?
At minimum: VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY for Supabase connectivity. If your app uses Stripe: VITE_STRIPE_PUBLISHABLE_KEY on the client side, and STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET as server-side variables. Any other API keys your app uses (OpenAI, Resend, etc.) must also be added. The complete list is in your Lovable editor under Settings → Environment.
Why does my site show 'Oops! Something went wrong and we couldn't publish your site'?
This Lovable platform error usually means the build process failed — most commonly a TypeScript error that generates exit code 1. Check the build log in the Lovable editor for the specific file and line. Fix the TypeScript error (or revert the last prompt that introduced it) and attempt to publish again. If the error persists, check whether the Lovable status page shows a platform incident.
Do I need to set up environment variables separately in Lovable and in my hosting provider?
Yes. Lovable's editor environment variables are used by the in-editor preview only. Your hosting provider (Vercel, Netlify, Cloudflare Pages, etc.) needs its own copy of every variable. They are not synced automatically. This is the Vanishing Env-Var problem — the most common cause of 'preview works but live breaks.'
My custom domain has been 'pending' for 48 hours — is that normal?
No. DNS propagation for a new domain connection typically completes in under 24 hours for most registrars. If your custom domain is still pending after 48 hours, check: (1) that the A record points to the IP address Lovable specified, (2) that you do not have a conflicting AAAA record, and (3) if using Cloudflare, that the proxy (orange cloud) is turned off — DNS-only mode is required for Lovable's domain verification to succeed.

App down or leaking data? Get an expert on it within 24–48h.

Book a free 30-minute audit call. We'll diagnose what's wrong and tell you exactly what it costs to fix.

Get emergency help