Skip to content

Commit 7ab655c

Browse files
Merge branch 'cloudflare:production' into production
2 parents 3a9ff4a + 1ac9e1f commit 7ab655c

File tree

24 files changed

+184
-26
lines changed

24 files changed

+184
-26
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Access your Worker's environment variables from process.env
3+
description: With Node.js compatability on, process.env is automatically populated with environment variables and secrets
4+
products:
5+
- workers
6+
date: 2025-03-11T15:00:00Z
7+
---
8+
9+
You can now access [environment variables](/workers/configuration/environment-variables/) and
10+
[secrets](/workers/configuration/secrets/) on [`process.env`](/workers/runtime-apis/nodejs/process/#processenv)
11+
when using the [`nodejs_compat` compatability flag](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag).
12+
13+
```js
14+
const apiClient = ApiClient.new({ apiKey: process.env.API_KEY });
15+
const LOG_LEVEL = process.env.LOG_LEVEL || "info";
16+
```
17+
18+
In Node.js, environment variables are exposed via the global `process.env` object. Some libraries
19+
assume that this object will be populated, and many developers may be used to accessing variables
20+
in this way.
21+
22+
Previously, the `process.env` object was always empty unless written to in Worker code. This could
23+
cause unexpected errors or friction when developing Workers using code previously written for Node.js.
24+
25+
Now, [environment variables](/workers/configuration/environment-variables/),
26+
[secrets](/workers/configuration/secrets/), and [version metadata](/workers/runtime-apis/bindings/version-metadata/)
27+
can all be accessed on `process.env`.
28+
29+
After April 1, 2025, populating `process.env` will become the default behavior when `nodejs_compat` is enabled, and
30+
your Worker's compatability date is after "2025-04-01". Until then, users can opt-in to this behavior by adding the
31+
[`nodejs_compat_populate_process_env`](/workers/configuration/compatibility-flags/#enable-auto-populating-processenv)
32+
compatability flag.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: "Enable auto-populating `process.env`"
3+
sort_date: "2025-02-27"
4+
enable_date: "2025-04-01"
5+
enable_flag: "nodejs_compat_populate_process_env"
6+
disable_flag: "nodejs_compat_do_not_populate_process_env"
7+
---
8+
9+
When you enable the `nodejs_compat_populate_process_env` compatibility flag and the [`nodejs_compat`](/workers/runtime-apis/nodejs/)
10+
flag is also enabled, `process.env` will be populated with values from any bindings with text or JSON values.
11+
This means that if you have added [environment variables](/workers/configuration/environment-variables/),
12+
[secrets](/workers/configuration/secrets/), or [version metadata](/workers/runtime-apis/bindings/version-metadata/)
13+
bindings, these values can be accessed on `process.env`.
14+
15+
```js
16+
const apiClient = ApiClient.new({ apiKey: process.env.API_KEY });
17+
const LOG_LEVEL = process.env.LOG_LEVEL || "info";
18+
```
19+
20+
This makes accessing these values easier and conforms to common Node.js patterns, which can
21+
reduce toil and help with compatability for existing Node.js libraries.
22+
23+
If users do not wish for these values to be accessible via `process.env`, they can use the
24+
`nodejs_compat_do_not_populate_process_env` flag. In this case, `process.env` will still be
25+
available, but will not have values automatically added.

src/content/docs/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/as-a-service/windows.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ By default, Cloudflare Tunnel expects all of the configuration to exist in the `
6464
cloudflared.exe tunnel create <Tunnel Name>
6565
```
6666

67-
This will generate a [credentials file](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#credentials-file) in `.json` format.
67+
This will generate a [credentials file](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#credentials-file) in `.json` format.
6868

6969
10. [Create a configuration file](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/create-local-tunnel/#4-create-a-configuration-file) with the following content:
7070

src/content/docs/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/create-local-tunnel.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ cloudflared tunnel login
105105
Running this command will:
106106

107107
- Open a browser window and prompt you to log in to your Cloudflare account. After logging in to your account, select your hostname.
108-
- Generate an account certificate, the [cert.pem file](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#certpem), in the [default `cloudflared` directory](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#default-cloudflared-directory).
108+
- Generate an account certificate, the [cert.pem file](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#certpem), in the [default `cloudflared` directory](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#default-cloudflared-directory).
109109

110110
## 3. Create a tunnel and give it a name
111111

@@ -116,7 +116,7 @@ cloudflared tunnel create <NAME>
116116
Running this command will:
117117

118118
- Create a tunnel by establishing a persistent relationship between the [name you provide](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#tunnel-name) and a [UUID](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#tunnel-uuid) for your tunnel. At this point, no connection is active within the tunnel yet.
119-
- Generate a [tunnel credentials file](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#credentials-file) in the [default `cloudflared` directory](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#default-cloudflared-directory).
119+
- Generate a [tunnel credentials file](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#credentials-file) in the [default `cloudflared` directory](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#certpem).
120120
- Create a subdomain of `.cfargotunnel.com`.
121121

122122
From the output of the command, take note of the tunnel's UUID and the path to your tunnel's credentials file.

src/content/docs/cloudflare-one/connections/connect-networks/routing-to-tunnel/dns.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This command create a `CNAME` record that points to the tunnel subdomain, but wi
4444

4545
:::note
4646

47-
To create DNS records using `cloudflared`, the [`cert.pem`](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#certpem) file must be installed on your system.
47+
To create DNS records using `cloudflared`, the [`cert.pem`](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#certpem) file must be installed on your system.
4848
:::
4949

5050
</TabItem>

src/content/docs/cloudflare-one/connections/connect-networks/routing-to-tunnel/lb.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This command creates an LB DNS record that points the specified hostname to the
3939

4040
:::note
4141

42-
To create DNS records using `cloudflared`, the [`cert.pem`](/cloudflare-one/connections/connect-networks/get-started/tunnel-useful-terms/#certpem) file must be installed on your system.
42+
To create DNS records using `cloudflared`, the [`cert.pem`](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#certpem) file must be installed on your system.
4343
:::
4444

4545
</TabItem>

src/content/docs/cloudflare-one/identity/devices/warp-client-checks/client-certificate.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Client Certificate device posture attribute checks if the device has a valid
3131

3232
- A CA that issues client certificates for your devices. WARP does not evaluate the certificate trust chain; this needs to be the issuing certificate.
3333
- Cloudflare WARP client is [deployed](/cloudflare-one/connections/connect-devices/warp/deployment/) on the device.
34-
- A client certificate is [installed and trusted](#how-warp-checks-for-a-client-certificate) on the device.
34+
- A client certificate is [installed and trusted](#configure-the-client-certificate-check) on the device.
3535

3636
:::note
3737

src/content/docs/cloudflare-one/identity/one-time-pin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ By design, blocked users will not receive an email. The login page will always s
8888

8989
:::note
9090

91-
Access only logs an authentication attempt after the user enters a code. If the user enters their email but never submits a code, the event will not appear in your [audit logs](/cloudflare-one/insights/logs/audit-logs/#authentication-audit-logs).
91+
Access only logs an authentication attempt after the user enters a code. If the user enters their email but never submits a code, the event will not appear in your [audit logs](/cloudflare-one/insights/logs/audit-logs/#authentication-logs).
9292
:::
9393

src/content/docs/cloudflare-one/identity/users/seat-management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 4
66
---
77

8-
Cloudflare Zero Trust subscriptions consist of seats that active users in your account consume. Active users are added to Zero Trust through any [authentication event](#authentication-event).
8+
Cloudflare Zero Trust subscriptions consist of seats that active users in your account consume. Active users are added to Zero Trust through any [authentication event](#authentication-events).
99

1010
The amount of seats available in your Zero Trust account depends on the amount of users you purchase. If you want to increase the number of seats available, you will have to purchase more users. Learn more about adding and removing seats from your account in the [Zero Trust FAQ](/cloudflare-one/faq/getting-started-faq/#how-do-i-change-my-subscription-plan).
1111

src/content/docs/cloudflare-one/policies/gateway/application-app-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Applications can be incompatible with [TLS decryption](/cloudflare-one/policies/
5858

5959
#### Application grouping
6060

61-
Gateway automatically groups applications incompatible with TLS decryption into the _Do Not Inspect_ app type. As Cloudflare identifies incompatible applications, Gateway will periodically update this app type to add new applications. To ensure Gateway does not intercept any current or future incompatible traffic, you can [create a Do Not Inspect HTTP policy](/cloudflare-one/policies/gateway/initial-setup/http/#bypass-inspection-for-incompatible-applications) with the entire _Do Not Inspect_ app type selected.
61+
Gateway automatically groups applications incompatible with TLS decryption into the _Do Not Inspect_ app type. As Cloudflare identifies incompatible applications, Gateway will periodically update this app type to add new applications. To ensure Gateway does not intercept any current or future incompatible traffic, you can [create a Do Not Inspect HTTP policy](/cloudflare-one/policies/gateway/http-policies/#do-not-inspect) with the entire _Do Not Inspect_ app type selected.
6262

6363
:::note[Install Cloudflare certificate manually to allow TLS decryption]
6464

0 commit comments

Comments
 (0)