#Stop overwriting existing routes with Worker Deploy with Wrangler

1 messages · Page 1 of 1 (latest)

dark mist
#

Hey guys, I'm trying to redeploy some workers but have noticed that the routes that have been added are getting wiped/overwritten with the routes in my wrangler.toml file. Is there anyway to stop this overwriting?

viral junco
# dark mist Hey guys, I'm trying to redeploy some workers but have noticed that the routes t...

Hey 👋

You should treat your wrangler.toml as your source of truth/configuration data. You can use --keep-vars to stop deployments from removing enviroment variables you set in the dashboard, but that doesn't work for routes.

If you change your routes in the dashboard, Wrangler will override them in the next deploy with the routes you have set in your wrangler.toml. To manage routes via the Cloudflare dashboard only, remove any route and routes keys from your wrangler.toml file. Then add workers_dev = false to your wrangler.toml file. For more information, refer to Deprecations.
https://developers.cloudflare.com/workers/wrangler/configuration/#source-of-truth

dark mist
#

Thanks for the response! Yeah I thought so... Do you know of any way to make deployments but to keep the routes persisting? I was thinking of using the --routes option in CLI deploy command but not sure how to set the zone_id for it. The last ditch effort is to set the routes via API after the deployment.

viral junco
#

You're specifically telling wrangler "I want these to be my routes", so it's overriding all the others. All you have to do is stop defining them

#

Adding them in the deploy command would result in the same issue

#

of course your other option would be to put all your routes in your wrangler.toml and use it to manage them