Then deploy to Cloudflare Workers it with the wrangler deploy command.
However, this configuration will cause the deployment to fail with the following error:
Your worker has access to the following bindings:
- D1 Databases:
- DB: db-stg (<stg-db-id>)
- DB: db (<prd-db-id>)
✘ [ERROR] A request to the Cloudflare API (/accounts/<accountId>/workers/scripts/<productName>) failed.
the binding name 'DB' cannot be used more than once [code: 10053]
If you think this is a bug, please open an issue at:
https://github.com/cloudflare/workers-sdk/issues/new/choose
Expected behavior
This is probably due to the fact that the value of env.stg is being read even though the environment variable has not been set.
If I set the environment variable to stg, this works fine.
However, I don't want the production app name to have -prd attached to it, so I want to deploy it with empty environment variables.
Which Cloudflare product(s) does this pertain to?
Wrangler core
What version(s) of the tool(s) are you using?
3.61.0
What version of Node are you using?
v22.1.0
What operating system and version are you using?
Sonoma 14.4.1
Describe the Bug
Observed behavior
I want to use different D1 for the validation environment and the production environment. To do so, I set up wrangler.toml as follows:
Then deploy to Cloudflare Workers it with the
wrangler deploy
command.However, this configuration will cause the deployment to fail with the following error:
Expected behavior
This is probably due to the fact that the value of
env.stg
is being read even though the environment variable has not been set.If I set the environment variable to
stg
, this works fine.However, I don't want the production app name to have
-prd
attached to it, so I want to deploy it with empty environment variables.Thanks for reading.
Please provide a link to a minimal reproduction
https://github.com/ogadra/empty-variable-in-wrangler
Please provide any relevant error logs
No response