Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Local dev: .dev.vars does not override bindings.text() values from cloudflare.config.ts

Aperta
#379 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
devtools, tooling

Direzione di ricerca

Start by tracing how local development loads .dev.vars and how bindings.text(...) and bindings.json(...) values from cloudflare.config.ts become worker bindings. Compare that path with Wrangler's local override behavior. Done means local values override configured text and JSON values while deploys still use the config values, or the issue explains the intended behavior and documents a recommended local setup.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

In local dev, a value declared with bindings.text(...) in cloudflare.config.ts cannot be overridden from .dev.vars. The config value always wins. With Wrangler, .dev.vars overrides vars locally, so you can keep the production value in the config and a local value (e.g. a localhost origin) in .dev.vars. That pattern doesn't work with cf.

Versions

  • cf 1.0.0-beta.18
  • @cloudflare/config 0.27.0
  • @cloudflare/vite-plugin 2.0.0-beta.v.1
  • vite 8.3.0, local dev via vite dev

Reproduction

cloudflare.config.ts:

env: {
  APP_ORIGIN: bindings.text("https://example.workers.dev"),
  PROBE_VAR: bindings.text("from-config"),
  SIGNING_KEY: bindings.secret(),
},

.dev.vars:

APP_ORIGIN=http://localhost:3100
PROBE_VAR=from-dev-vars
PROBE_ONLY_DEVVARS=devvars-loaded
SIGNING_KEY=...

Worker:

return Response.json({
  APP_ORIGIN: env.APP_ORIGIN,
  PROBE_VAR: env.PROBE_VAR,
  PROBE_ONLY_DEVVARS: env.PROBE_ONLY_DEVVARS,
  hasSigningKey: !!env.SIGNING_KEY,
});

Actual

{"PROBE_VAR":"from-config","APP_ORIGIN":"https://example.workers.dev","hasSigningKey":true}
  • .dev.vars is read (the declared secret SIGNING_KEY is populated).
  • Keys declared with bindings.text(...) keep the config value; .dev.vars is ignored for them.
  • Keys only present in .dev.vars (not declared in the config) are not exposed at all.

Expected

Matching Wrangler, a key in .dev.vars (or .env) should override a bindings.text(...) / bindings.json(...) value during local dev, while deploys keep using the config value.

If the current behaviour is intentional, it would help to document it and suggest a recommended way to have different local and production values for plain-text vars (today the only workaround is to declare them as bindings.secret() and set production values out of band).

Lingua principale
TypeScript
Stelle
916
Fork
53
Merge medio
19h 13m
PR unite (30g)
185

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudflare/cf

Tutte le issue di cloudflare/cf

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.