Error library

Symptom: env vars undefined after Cloudflare Pages build

Cloudflare Pages only passes variables you set in the project's settings to the build, separately for Production and Preview, and a Vite/static build bakes them in at build time. Add the variables in Workers & Pages > your project > Settings for the right environment, then trigger a new deployment.

Cause: Variables were set locally or for the wrong environment (Preview vs Production), or added after the last build.

How to fix it

  1. In the Cloudflare dashboard open Workers & Pages > project > Settings > Variables.
  2. Add each variable for Production and Preview as needed (with VITE_ prefix for Vite client vars).
  3. Retry/redeploy: existing deployments do not pick up new values.
  4. Use CF_PAGES_BRANCH etc. if build logic depends on branch.

In Supabase apps this symptom often surfaces as Error: supabaseUrl is required. in the browser console.

Example

Illustrative example, not from a customer project.

  # Pages > Settings > Variables (Production)
+ VITE_SUPABASE_URL = https://xyz.supabase.co
+ VITE_SUPABASE_ANON_KEY = <public anon key>

FAQ

I added the variable; why is it still undefined?

The value is read at build time. Trigger a new deployment.

Preview works but production doesn't.

Production and Preview have separate variable sets.

Get a $149 diagnosis See pricing Launching soon? The Launch Path gets you ready for $1,195 flat.

$149Get a $149 diagnosis