Common errors · Lovable, Bolt, Cursor projects on Vercel, Netlify, Railway
Environment variables undefined in production (Vite, Next.js)
Cause Client variables are baked in at build time and need the VITE_ or NEXT_PUBLIC_ prefix; the host never received your .env.
Fix Add each variable in the host dashboard with the right prefix, then rebuild. Secrets stay server-side, without the prefix.
Have it fixed for you, 290 EURSee the fix step by step
Everything works in the editor preview, the deployed site shows a blank page and this error in the console. The variables existed in the builder, not on your host.
Where it breaks
Which case is yours?
- Client-side variables are baked in at build time. Vite only exposes names starting with VITE_, Next.js only NEXT_PUBLIC_. Adding them after the build changes nothing until you rebuild.
- The .env file is not committed (correctly), so the host never received the values.
The fix, step by step
- List what the code reads.
grep -rhoE "(import\.meta\.env|process\.env)\.[A-Z0-9_]+" src app | sort -u - Add each one in the host dashboard with the right prefix (VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY...), for the production environment, then trigger a new build.
- Only public values go behind VITE_ or NEXT_PUBLIC_. The Supabase service_role key, Stripe secret key and any API secret stay server-side (Edge Function, API route) without the prefix.
- Fail loudly at start-up so a missing value never ships again.
if (!import.meta.env.VITE_SUPABASE_URL) throw new Error("VITE_SUPABASE_URL missing at build time");
How to check it is fixed
View the page source of the deployed build and search for your Supabase project ref: it is present, and no sk_live_ or service_role string is.
Delivery example for this error
- process.env.SUPABASE_URL+ import.meta.env.VITE_SUPABASE_URL+ // + set it before the build- Root cause: Client variables are baked in at build time and need the VITE_ or NEXT_PUBLIC_ prefix; the host never received your .env.
- Change made: Add each variable in the host dashboard with the right prefix, then rebuild. Secrets stay server-side, without the prefix.
- View the page source of the deployed build and search for your Supabase project ref: it is present, and no sk_live_ or service_role string is.
Illustrative: the real diff is written against your repository. Full sample report
Still stuck on your own code?
Send the repository and the exact error. Fix: 290 EUR all taxes included, delivered within 72 hours, refunded if not resolved.
Not sure it is this error? Ask for a free written diagnosis, no card needed.