- White/blank page in production; console shows “supabaseUrl is required” or undefined API keys
- App worked inside Lovable/Bolt/Replit but not on Netlify/Vercel/Cloudflare
- You added variables in the dashboard but nothing changed
Why it happens
Builders inject keys for you; your .env file is (correctly) not in Git, so the new host builds without them. With Vite, only variables starting with VITE_ are exposed to browser code, and they're replaced at build time — so changing them requires a rebuild.
How to fix it
-
Find the variable names your code uses
Search the code for import.meta.env (Vite) or process.env (Node/Next.js). Lovable projects typically use VITE_SUPABASE_URL, VITE_SUPABASE_PUBLISHABLE_KEY and VITE_SUPABASE_PROJECT_ID.
grep -rn "import.meta.env\|process.env" src -
Add them in your host's dashboard
Vercel: Project → Settings → Environment Variables. Netlify: Project configuration → Environment variables. Cloudflare Pages: Settings → Environment variables. Names must match exactly, including the VITE_ prefix.
-
Trigger a fresh build
Vite bakes values in at build time; redeploying the old build won't pick them up. Clear cache and redeploy.
-
Never put secrets in VITE_ variables
Anything prefixed VITE_ ends up in public JavaScript. The Supabase publishable/anon key is meant to be public (protected by RLS); a service_role key or Stripe secret key is not.