DEV Community

Axonscape
Axonscape

Posted on Originally published at launchpad.axonscape.com

Works locally, blank or broken in production: missing environment variables

The deployed app shows a blank page or errors that never happen locally. Usually a key the code reads was set on your computer, or in the AI tool, and never on the host.

What you see

A white screen, supabaseUrl is required, undefined in place of a value, or sign-in redirecting to localhost, only once deployed.

Why it happens

The code reads values like VITE_SUPABASE_URL from the environment. Your .env file, or the tool's secrets panel, set them where you built it; the new host has none of them. Links or sign-in redirects written as http://localhost:… break in the same way.

How to fix it

  1. List every variable the code reads (process.env.X, import.meta.env.X) in a .env.example, names only.
  2. Set each one at the host for production and previews. Values that start with NEXT_PUBLIC_ or VITE_ are visible to everyone: never put a secret in one.
  3. Replace hard-coded localhost addresses with a variable such as NEXT_PUBLIC_SITE_URL.
  4. Redeploy: most hosts only read variables at build time.

Or ask your AI tool to fix it

Paste this into Lovable, Bolt, v0, Replit or Cursor:

My app works locally but not when deployed. List every environment variable the code reads in .env.example (names only, no values), and replace any hard-coded localhost URL with one read from an environment variable. Don't put any secret value in the code.


The full page, with the request ready to copy, is at launchpad.axonscape.com/fix/missing-environment-variables-in-production. I work on Launchpad by Axonscape, which runs a free launch check for apps built with AI tools: it finds this and the other things that break at launch, from a public GitHub repo or a .zip of the code, and keeps nothing.

Top comments (0)