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.
| Overrides | Variable names |
|---|---|
| Worker name | INSIGHTFLARE_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 name | INSIGHTFLARE_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_MINUTESSCRIPT_CACHE_TTL_SECONDSPARQUET_WASM_URLDEMO_MODEDISABLE_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_IDINSIGHTFLARE_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_SECRETare not written towrangler.toml. Set them as secrets instead.