Vars cloudflare workers
I'm experiencing an issue where environment variables set via the Cloudflare dashboard are being erased after each deployment. My wrangler.json defines empty vars, but even after populating them in the dashboard, new deployments reset all values to empty. How can I preserve my environment variables between deployments?
Even after completely removing the "vars" section from my wrangler config, the problem persists with CI/CD deployments still wiping out all variable values.
1 Reply
Your wrangler toml/json is seen as the source of truth, and it resetting/removing all the normal env vars on next deploy is intended.
If they're secrets, secrets are defined seperately and not overridden, otherwise you should define them in your json with the actual values
https://developers.cloudflare.com/workers/wrangler/configuration/#source-of-truth
Cloudflare Docs
Configuration
Use a configuration file to customize the development and deployment setup for your Worker project and other Developer Platform products.