aiRepoFix / How-to fixes

App works in preview but is blank (or 401) after deploy: environment variables

Last checked against vendor documentation: October 17, 2026.

Short answer: your local .env file usually does not travel to your host. Add each variable in the host's own settings, use the VITE_ prefix for values the browser needs (if your app is built with Vite), then rebuild and redeploy. Changing a variable does not fix a deploy that is already live.

Symptoms

Check this first (about five minutes)

  1. Open the live site, then open the browser developer tools (usually F12). Look at the Console tab for red errors and the Network tab for failed (red) requests. Note the first error. It is often the real cause.
  2. Open your project's .env file locally and list the variable names (not the values). Make sure each one is set at your host.
  3. If your app uses Vite (Lovable's own docs show VITE_ variables for its projects), check that every value the browser needs starts with VITE_.
  4. Check you redeployed after adding the variables.

Why it happens

Fix by host

Netlify

  1. Open your site, then Project configuration > Environment variables.
  2. Add each variable (for example VITE_SUPABASE_URL) with its value. Netlify's docs say its build does not read a .env file from your repository, and that you can instead use Add a variable > Import from a .env file to bring the values in to your own Netlify account (the Netlify CLI has env:import). Only import values that belong at the host, and never paste or send a .env file to anyone else.
  3. Trigger a new build and deploy. Netlify's docs say environment variable changes require a build and deploy to take effect.

Vercel

  1. Open your project, then choose Environment Variables in the sidebar.
  2. Enter the Name and Value, pick the environments it applies to (Production for your live site), and click Save.
  3. Redeploy. Vercel's docs say changes are not applied to previous deployments, only to new ones.

Replit

  1. Open the Secrets tool (Tools, then Setup, then Secrets) and add each value.
  2. To check what your published app uses, open Publishing, choose Adjust settings, and look at Production app secrets. Replit notes testing and production can use different values.
  3. Replit's docs say Secrets are not available on Static deployments. Apps built with Replit Agent are not compatible with Static deployments (use Autoscale or Reserved VM).
  4. Publish again so the live app is rebuilt. Replit's secrets page doesn't spell out whether a new publish is required after a change, so doing one is the safe choice.

Safety: what may go in a VITE_ variable

Anything with the VITE_ prefix is shipped to every visitor's browser. Vite's docs say VITE_* variables should not contain sensitive information such as API keys.

After changing variables

  1. Wait for the new build to finish on the host.
  2. Hard-refresh the live site (Ctrl+Shift+R, or Cmd+Shift+R on a Mac) or use a private window, so you are not looking at a cached copy.
  3. Reopen the Console and Network tabs and check the error is gone.

If variables are not the cause

A blank page after deploy has other causes. Two common ones:

If the Console shows an error that mentions your own code rather than a missing value, the cause is probably in the code.

What you can do yourself, and when it is a code change. Setting variables at your host is a dashboard task you do yourself. We can't access your hosting dashboard. If the cause is in your code (wrong variable names, a secret in a VITE_ variable, a wrong base, missing rewrite rules), that is a change in your repo, and we deliver it as a pull request. If part of the fix is a setting for you to change, we list it in the pull request notes. Don't send us the values: we never need your keys or .env file.

Sources

This page is based on the vendor documentation below. Menu names and defaults change, so check the source if something on your screen looks different.

Last checked: October 17, 2026. aiRepoFix is not affiliated with or endorsed by the companies named on this page.

Still stuck? Describe it free.

Tell us what is broken. We review it and either email you the flat price for the tier that fits ($49 Quick, $99 Standard, $149 Full) with a payment link, or tell you we can't take it, and you pay nothing. The fix comes as a pull request you review, and nothing in your app changes until you merge it. Pull request delivered within 96 hours of a complete order (weekends and US holidays don't count), or 20% back. (conditions apply)

Please don't send passwords, API keys or .env files. We don't need them.

aiRepoFix is an independent service that fixes bugs in the code in your own GitHub repository and delivers a pull request; it is not technical support for Lovable, Supabase, Cursor, Bolt, Replit or any other platform mentioned on this page.

Still stuck? Describe it free →