Documentation
02Deployment

Configuration overrides

Override Wrangler settings with Cloudflare build variables, and the full list of supported names.

In a Cloudflare build environment, project variables and secrets can override deployment-specific values in wrangler.toml. The prebuild step (build:pre) reads these values before deployment, writes them into the active Wrangler configuration, and the following wrangler deploy uses the resolved file.

Supported variables

For each setting, the first non-empty name in the list that is set in the environment is used.

OverridesVariable names
Worker nameINSIGHTFLARE_WORKER_NAME, CLOUDFLARE_WORKER_NAME
D1 database name (binding DB)INSIGHTFLARE_D1_DATABASE, INSIGHTFLARE_D1_DATABASE_NAME, D1_DATABASE_NAME
D1 database ID (binding DB)INSIGHTFLARE_D1_DATABASE_ID, D1_DATABASE_ID, DB_DATABASE_ID
KV namespace ID (binding SITE_SETTINGS_KV)INSIGHTFLARE_SITE_SETTINGS_KV_ID, INSIGHTFLARE_KV_NAMESPACE_ID, SITE_SETTINGS_KV_ID, KV_NAMESPACE_ID
R2 bucket name (binding ARCHIVE_BUCKET)INSIGHTFLARE_ARCHIVE_BUCKET_NAME, ARCHIVE_BUCKET_NAME, R2_BUCKET_NAME
R2 preview bucket nameINSIGHTFLARE_ARCHIVE_PREVIEW_BUCKET_NAME, ARCHIVE_PREVIEW_BUCKET_NAME, R2_PREVIEW_BUCKET_NAME

The following [vars] entries can be overridden by using their own names:

  • SESSION_WINDOW_MINUTES
  • SCRIPT_CACHE_TTL_SECONDS
  • PARQUET_WASM_URL
  • DEMO_MODE
  • DISABLE_CRON_TASKS

Arbitrary variables

Any [vars] entry can be written with the prefix INSIGHTFLARE_VAR_. For example, INSIGHTFLARE_VAR_FEATURE_FLAG=1 becomes FEATURE_FLAG = "1" in [vars].

Named Wrangler environments

When you deploy with --env production, the environment name is added to the prefix, and values are written into [env.production]. For the named settings above, the environment-specific name takes priority over the generic one. Examples:

  • INSIGHTFLARE_PRODUCTION_D1_DATABASE_ID
  • INSIGHTFLARE_PRODUCTION_VAR_FEATURE_FLAG

Non-alphanumeric characters in the environment name are replaced with _ and the name is upper-cased.

Notes

  • Empty values are ignored.
  • The override step edits the Wrangler file in place during the build. If a binding table such as [[r2_buckets]] is absent, setting the R2 bucket name creates it; for D1 and KV, the existing binding is updated.
  • Secrets such as MAIN_SECRET are not written to wrangler.toml. Set them as secrets instead.