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.

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

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.

QUICK FIX · $49 · THIS ERROR ONLY

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.

Bigger job: Getting the whole app live? Launch Path, $1,195 flat.

Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.

Check it yourself first, free

$49Fix this error