Skip to content

What is the proper way to use environments with generated wrangler config? #3429

Description

@mohamnag

Environment

node v22.16.0
wrangler 4.22.0
nitropack 2.11.13

Reproduction

check this code: https://github.com/mohamnag/nitro-wrangler-bug
run: npm run build && npx wrangler dev

see the error

Describe the bug

I have been using wrangler configured with a standalone wrangler.jsonc file to manage deployments to different environments where I just discovered the new cloudflare config for cloudflare_module preset. this would simplify life a bit for me as some things like the compatibility date does not need to be set in many places and things that can be configured by nitro itself can be taken care of too. however it looks like the wrangler does not like the generated file having different environments in it. I'm getting the following error trying to deploy the results or even run it in preview mode:

 ⛅️ wrangler 4.22.0
───────────────────
Using redirected Wrangler configuration.
 - Configuration being used: ".output/server/wrangler.json"
 - Original user's configuration: "wrangler.jsonc"
 - Deploy configuration file: ".wrangler/deploy/config.json"

✘ [ERROR] Processing .output/server/wrangler.json configuration:

    - Redirected configurations cannot include environments but the following have been found:
      	- production


      Such configurations are generated by tools, meaning that one of the tools
      your application is using is generating the incorrect configuration.
      Report this issue to the tool's author so that this can be fixed there.

I can workaround this by giving wrangler the generated config file directly (i.e. -c .output/server/wrangler.json) but that is a bit shaky to me (as the file can be renamed, ...). Is there a solid concept on how one is supposed to still use the wrangler's feature for managing different environments without this workaround and without hitting that error?

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions