Vibe-Code Rescue

Error: supabaseUrl is required.

Why it happens

The app works in the builder or on your laptop, then shows a blank page in production with this error in the console. The Supabase client is being created with an empty URL, which means the environment variable did not reach the build.

Two things cause that. Vite only exposes variables that start with VITE_ to browser code. And Vercel only applies a variable to deployments made after you added it.

How to fix it

  1. Find the names your code reads. In a Vite app they look like import.meta.env.VITE_SUPABASE_URL.
    grep -rn "import.meta.env" src
  2. In the Vercel dashboard open the project, then Settings, then Environment Variables. Add each name exactly as the code spells it, with the VITE_ prefix, and tick the Production environment.
  3. You can do the same from the command line. It asks you for the value.
    vercel env add VITE_SUPABASE_URL production
    vercel env add VITE_SUPABASE_ANON_KEY production
  4. Redeploy. Vercel says changes to environment variables do not apply to earlier deployments, so a new deployment is required.
    vercel --prod
  5. Reload the live site and check the console. The error should be gone.

Only put values in VITE_ variables that are safe to show to every visitor, such as the project URL and the public key. Vite warns that VITE_ variables must not hold secrets. A service role key or a Stripe secret key never goes there.

When it is not this

Questions

Why is supabaseUrl required in production but fine locally?

Your local .env file is not part of the Vercel build. Add the variables in Vercel with the VITE_ prefix, then redeploy.

Do I need to redeploy after adding an environment variable on Vercel?

Yes. Vercel says the change applies only to new deployments.

Sources

Still broken?

The free health check asks ten questions about your app and shows the three fixes to do first. It runs in your browser.

If you would rather have someone read the code, the fixed-price audit is $497 one-time. It covers security and scaling, with a written report ranked by severity.