Blank page after deploy? Check your production env vars

Your site works in the editor preview. You publish it, open the live URL, and get a white screen. One of the most common causes is environment variables that exist in the preview but not in the production build.

The symptom

  • A blank page on the live site, or a page with no data, while the preview looks fine. It often starts right after a first deploy or a host move.
  • Console errors such as supabaseUrl is required, Missing API key or Cannot read properties of undefined.
  • Network requests going to https://yoursite.com/undefined/... or to localhost.

The cause

Your code reads settings like the database URL or a publishable key from environment variables, so they don't have to be written into the code. In the editor, those values come from a local .env file or the builder's own settings. Your host doesn't see that file. It is usually kept out of Git on purpose, so the production build runs without it.

Two details make this worse. First, in front-end frameworks the values are baked in at build time. Vite only exposes variables that start with VITE_, and Next.js only exposes ones that start with NEXT_PUBLIC_ to the browser. If a variable was missing when the site was built, adding it later changes nothing until you build again. Second, a wrong prefix fails silently: the variable is simply undefined in the browser.

Diagnose it step by step

  1. Open the live site in a private window and press F12. Look at the Console for the errors above.
  2. Open the Network tab and reload. Look for requests to undefined, localhost or an old domain, and for 401 or 403 responses that suggest a missing or wrong key.
  3. Search your code for import.meta.env or process.env and list every variable the front end uses.
  4. Compare that list with the variables set on your host for the production environment. Check spelling and prefixes exactly.
  5. Check the date of the last production build. If it is older than your last variable change, the live site is still using the old values.

Fixes per builder and host

Lovable

On Lovable's own hosting, the connection to your database is set up for you. Problems usually appear after you export to GitHub and deploy elsewhere. Copy the VITE_ values your code uses into the new host's settings. Secrets used by backend functions belong in the backend's secrets, not in the front end.

Bolt

Check the .env file in the project's file tree. If you deploy to Netlify, make sure the same variables are set on the Netlify site (below), then redeploy from Bolt.

Replit

Add values in the Secrets tool, then check that your deployment has them too in the Deployments settings. Republish after any change. A static deployment is built once, so new values need a new deploy.

v0

Set variables in the project's settings in v0. When the site runs on Vercel, they must also exist in the Vercel project for Production. Anything the browser needs must start with NEXT_PUBLIC_.

Cursor

Cursor doesn't host anything, so the fix is wherever you deploy. Your .env.local stays on your machine. Ask Cursor to "list every environment variable this project reads", then add each one to your host.

Netlify

Go to Site configuration, then Environment variables. Make sure each variable is available to builds and to the production context. Then use Deploys, Trigger deploy, Clear cache and deploy site.

Vercel

Go to Settings, then Environment Variables, and tick Production for each one. Changes only apply to new deployments, so redeploy the latest production deployment afterwards.

Cloudflare Pages

Go to your Pages project, Settings, then Variables and Secrets. Production and Preview are set separately. Add the values for Production and start a new deployment, because the build needs them.

Supabase

Copy the Project URL and the anon (publishable) key from your project's API settings. Never put the service_role or secret key in a VITE_ or NEXT_PUBLIC_ variable: those ship to every visitor's browser. Secrets for Edge Functions go in the Edge Functions secrets, set in the dashboard or with supabase secrets set.

How to verify the fix

  • After the new deploy, open the live site in a private window. The page should render and the console should be free of the errors you saw.
  • In the Network tab, requests should go to the real API URL, not undefined or localhost.
  • Test the features that need the variables: load data, sign in, send a form.

Prevention

  • Keep a .env.example file in the repo listing every variable name, with no real values.
  • Add a startup check that shows a clear message when a required variable is missing, instead of a blank page.
  • When you move hosts or rotate a key, update the host first, redeploy, then test the live site.

FlowCanary opens your live site the way a visitor would and reports blank pages and console errors, with a copy-paste fix prompt for your builder.

Run the free 30-second check

Run the free 30-second check

← All posts

FlowCanary on SaaSHub