worker routes not correctly assigned to wrangler env routes

i'm having a wrangler config that defines two environments - staging and production.
under each env, i added a route so the DNS can be created and assigned to the specific env/worker

 "env": {
    "staging": {
      "name": "worker-staging",
      "routes": [
        {
            "pattern": "staging.example.com",
            "custom_domain": true,
            "zone_name": "example.com",
        }
      ],
      ...
    },
    "production": {
      "name": "worker-production",
      "routes": [
        {
              "pattern": "example.com",
             "custom_domain": true,
             "zone_name": "example.com",
        },
      ],
      ...
    }
 }
}


however, when i'm deploying the staging worker wrangler deploy --env staging both DNS records gets created and assigned to worker-staging instead of a single one (staging.example.com that should be assigned to the staging-worker)
Was this page helpful?