Skip to content

Fix text about referencing environment variables from Worker code #28834

@klyakh

Description

@klyakh

Existing documentation URL(s)

https://developers.cloudflare.com/workers/wrangler/environments/#staging-and-production-environments

What changes are you suggesting?

Currently it says:


Any defined environment variables (the vars key) are exposed as global variables to your Worker.

With this configuration, the ENVIRONMENT variable can be used to call specific code depending on the given environment:

if (ENVIRONMENT === "staging") {
  // staging-specific code
} else if (ENVIRONMENT === "production") {
  // production-specific code
}

But the ENVIRONMENT variable is available via env.ENVIRONMENT.

Need to update the wrong statement and the code example.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions