You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers/configuration/environment-variables.mdx
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,8 +49,8 @@ export default {
49
49
50
50
### Configuring different environments in Wrangler
51
51
52
-
You can set up [environments in Wrangler](/workers/wrangler/environments), and specify different values for your environment variables in each environment.
53
-
`vars` is a non-inheritable key. [Non-inheritable keys](/workers/wrangler/configuration/#non-inheritable-keys) are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
52
+
[Environments in Wrangler](/workers/wrangler/environments) let you specify different configurations for the same worker, including different values for `vars` in each environment.
53
+
As `vars` is a [non-inheritable key](/workers/wrangler/configuration/#non-inheritable-keys), they are not inherited by environments and must be specified for each environment.
54
54
55
55
The example below sets up two environments, `staging` and `production`, with different values for `API_HOST` and `API_ACCOUNT_ID`.
To run Wrangler commands in specific environments, you can pass in the `--env` or `-e` flag. For example, you can develop the Worker in the `dev` environment by running `npx wrangler dev -e=staging`, and deploy it with `npx wrangler deploy -e=production`.
73
+
To run Wrangler commands in specific environments, you can pass in the `--env` or `-e` flag. For example, you can develop the Worker in an environment called `staging`by running `npx wrangler dev --env=staging`, and deploy it with `npx wrangler deploy --env=staging`.
76
74
77
75
Learn about [environments in Wrangler](/workers/wrangler/environments).
- To bind to a Worker in a specific [environment](/workers/wrangler/environments), you need to append the environment name to the Worker name. This should be in the format `<worker-name>-<environment-name>`. For example, to bind to a Worker called `worker-name` in its `staging` environment, `service` should be set to `worker-name-staging`.
Copy file name to clipboardExpand all lines: src/content/docs/workers/wrangler/environments.mdx
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,11 @@ description: Use environments to create different configurations for the same Wo
8
8
import { WranglerConfig } from"~/components";
9
9
10
10
Wrangler allows you to use environments to create different configurations for the same Worker application. Environments are configured in the Worker's [Wrangler configuration file](/workers/wrangler/configuration/).
11
+
There is a default (top-level) environment and you can create named environments that provide environment-specific configuration.
11
12
12
13
Review the following environments flow:
13
14
14
-
1.You have created a Worker, named `my-worker` for example.
15
+
1.Create a Worker, named `my-worker` for example.
15
16
2. Create an environment, for example `dev`, in the Worker's [Wrangler configuration file](/workers/wrangler/configuration/), by adding a `[env.<ENV_NAME>]` section.
16
17
17
18
<WranglerConfig>
@@ -55,7 +56,7 @@ Cloudflare effectively creates a new Worker for you when you create a Worker wit
55
56
56
57
[Non-inheritable keys](/workers/wrangler/configuration/#non-inheritable-keys) are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
57
58
58
-
[Bindings](/workers/runtime-apis/bindings/) and [environment variables](/workers/configuration/environment-variables/) must be specified per each[environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/).
59
+
For example, [bindings](/workers/runtime-apis/bindings/) and [environment variables](/workers/configuration/environment-variables/)are non-inheritable, and must be specified per [environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/).
59
60
60
61
Review the following example Wrangler file:
61
62
@@ -83,8 +84,8 @@ kv_namespaces = [
83
84
84
85
### Service bindings
85
86
86
-
To use a [service binding](/workers/wrangler/configuration/#service-bindings) that targets a Worker in a specific environment, you need to include the environment in`service` field. This should be in the format `<worker-name>-<environment-name>`.
87
-
In the example below, we have two Workers, both with a `staging` environment. `worker-b` has a service binding to `worker-a`. Note how the service binding in the `staging` environment points to `worker-a-staging`, whereas the top-level service binding points to `worker-a`.
87
+
To use a [service binding](/workers/wrangler/configuration/#service-bindings) that targets a Worker in a specific environment, you need to append the environment name to the target Worker name in the`service` field. This should be in the format `<worker-name>-<environment-name>`.
88
+
In the example below, we have two Workers, both with a `staging` environment. `worker-b` has a service binding to `worker-a`. Note how the `service` field in the `staging` environment points to `worker-a-staging`, whereas the top-level service binding points to `worker-a`.
0 commit comments