Kynson
05/17/2023, 1:31 PMwrangler publish --env dev
wrangler.toml:
name = 'foo'
account_id = '<ACC ID>'
main = 'src/index.ts'
workers_dev = false
routes = ["foo.com/_api/*", "www.foo.com/_api/*"]
kv_namespaces = [{ binding = 'CONTENT', id = '<KV ID>', preview_id = '<KV ID>' }]
compatibility_date = '2023-05-16'
[env.dev]
workers_dev = true
kv_namespaces = [ { binding = 'CONTENT', id = '<KV ID>', preview_id = '<KV ID>' }]
Issues faced:
- A new worker was created with the name 'foo-dev' (where foo is the original name of the 'production' worker), instead of adding a new environment to the existing foo worker
- The ''foo-dev' was mapped to all 3 routes i.e. foo.com/_api/\*, www.foo.com/_api/* and foo-dev.foo.workers.dev
Confusion:
- I was once able to publish a worker with 2 different environments without having a new worker being created. Yet I can't find the same way to do so now. (Please see the screenshot. The 'contact' worker has another environment called dev).
I tried the name the 'dev' worker with the same name 'foo' and the original one got overwritten.
- As shown on https://developers.cloudflare.com/workers/platform/environments/#staging-environment-with-workersdev I can set workers_dev
to true so it will only deploy to workers.dev. Yet, the all three routes are mapped to the new dev worker.
I am aware that routes
will be inherited so this might be an expected behaviour, but the documentation seem to be misleading (or maybe I got confused). May I know if there is a way to only deploy my worker to workers.dev for a specific environment.
Thank you for your help!
https://cdn.discordapp.com/attachments/1108386385536229526/1108386386274430976/Screenshot_2023-05-17_at_21.22.27.png▾
Isaac McFadyen | YYZ01
05/17/2023, 6:02 PMKynson
05/18/2023, 12:12 AM