shipfix

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.

supabaseUrl is required. / Cannot read properties of undefined (import.meta.env.VITE_...)

Have it fixed for you, 290 EURSee the fix step by step

What you receive a diff on a branch of your repository, and a correction note: root cause, change made, how to verify it. See a sample report

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

.env (local)never deployedHost buildno VITE_ variableBundleundefined baked inFix: host varsprefix + rebuildnotuploadedat buildtimethen.env (local)never deployedHost buildno VITE_ variableBundleundefined baked inFix: host varsprefix + rebuildnot uploadedat build timethen
Client variables are copied into the bundle at build time. Without the prefix, or without the value on the host, the bundle holds undefined.

Which case is yours?

  1. 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.
  2. The .env file is not committed (correctly), so the host never received the values.

The fix, step by step

  1. List what the code reads.
    grep -rhoE "(import\.meta\.env|process\.env)\.[A-Z0-9_]+" src app | sort -u
  2. 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.
  3. 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.
  4. 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

src/lib/env.ts · on a branch of your repository- process.env.SUPABASE_URL+ import.meta.env.VITE_SUPABASE_URL+ // + set it before the build
Verification checklist in the note
  • 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.

Private repository: paste its link anyway, we reply by email within one business day with the GitHub account to invite with read access. A zip link (Google Drive, Dropbox) works too. Never send passwords or secret keys in this form.

Fix: One blocking auth, Supabase RLS or deployment problem fixed in your repository.290 EUR all taxes included · 72 hours

Secure payment by Stripe. Not resolved within 72 hours: refunded in full.

Not sure it is this error? Ask for a free written diagnosis, no card needed.