Skip to content

Commit a687114

Browse files
update system environment variables page
1 parent c6db110 commit a687114

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/content/docs/workers/wrangler/system-environment-variables.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,66 @@ System environment variables are local environment variables that can change Wra
1616
3. Set the values in your shell environment. For example, if you are using Z shell, adding `export CLOUDFLARE_API_TOKEN=...` to your `~/.zshrc` file will set this token as part of your shell configuration.
1717

1818
:::note
19-
2019
To set different system environment variables for each environment, create files named `.env.<environment-name>`. When you use `wrangler <command> --env <environment-name>`, the corresponding environment-specific file will be loaded instead of the `.env` file, so the two files are not merged.
2120
:::
2221

22+
:::note
23+
During local development, the values in `.env` files are also loaded into the `env` object in your Worker, so you can access them in your Worker code.
24+
25+
For example, if you set `API_HOST="localhost:3000"` in your `.env` file, you can access it in your Worker like this:
26+
27+
```js
28+
const apiHost = env.API_HOST;
29+
```
30+
31+
See the [Environment variables and secrets](/workers/development-testing/environment-variables/) page for more information on how to use `.env` files in local development.
32+
:::
33+
2334
## Supported environment variables
2435

2536
Wrangler supports the following environment variables:
2637

2738
- `CLOUDFLARE_ACCOUNT_ID` <Type text="string" /> <MetaInfo text="optional" />
39+
2840
- The [account ID](/fundamentals/account/find-account-and-zone-ids/) for the Workers related account.
2941

3042
- `CLOUDFLARE_API_TOKEN` <Type text="string" /> <MetaInfo text="optional" />
43+
3144
- The [API token](/fundamentals/api/get-started/create-token/) for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation.
3245

3346
- `CLOUDFLARE_API_KEY` <Type text="string" /> <MetaInfo text="optional" />
47+
3448
- The API key for your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_EMAIL=`.
3549

3650
- `CLOUDFLARE_EMAIL` <Type text="string" /> <MetaInfo text="optional" />
51+
3752
- The email address associated with your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_API_KEY=`.
3853

3954
- `WRANGLER_SEND_METRICS` <Type text="string" /> <MetaInfo text="optional" />
55+
4056
- Options for this are `true` and `false`. Defaults to `true`. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md).
4157

4258
- `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING_NAME>`<Type text="string" /> <MetaInfo text="optional" />
59+
4360
- The [local connection string](/hyperdrive/configuration/local-development/) for your database to use in local development with [Hyperdrive](/hyperdrive/). For example, if the binding for your Hyperdrive is named `PROD_DB`, this would be `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:[email protected]:5432/testdb"`. Each Hyperdrive is uniquely distinguished by the binding name.
4461

4562
- `CLOUDFLARE_API_BASE_URL` <Type text="string" /> <MetaInfo text="optional" />
63+
4664
- The default value is `"https://api.cloudflare.com/client/v4"`.
4765

4866
- `WRANGLER_LOG` <Type text="string" /> <MetaInfo text="optional" />
67+
4968
- Options for Logging levels are `"none"`, `"error"`, `"warn"`, `"info"`, `"log"` and `"debug"`. Levels are case-insensitive and default to `"log"`. If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs.
5069

5170
- `WRANGLER_LOG_PATH` <Type text="string" /> <MetaInfo text="optional" />
71+
5272
- A file or directory path where Wrangler will write debug logs. If the path ends in `.log`, Wrangler will consider this the path to a file where all logs will be written. Otherwise, Wrangler will treat the path as a directory where it will write one or more log files using a timestamp for the filenames.
5373

5474
- `FORCE_COLOR` <Type text="string" /> <MetaInfo text="optional" />
5575
- By setting this to `0`, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example, `FORCE_COLOR=0`.
5676

5777
* `WRANGLER_HTTPS_KEY_PATH` <Type text="string" /> <MetaInfo text="optional" />
78+
5879
- Path to a custom HTTPS certificate key when running `wrangler dev`, to be used with `WRANGLER_HTTPS_CERT_PATH`.
5980

6081
* `WRANGLER_HTTPS_CERT_PATH` <Type text="string" /> <MetaInfo text="optional" />

0 commit comments

Comments
 (0)