Skip to content

Commit a8c4024

Browse files
committed
run prettier
1 parent ab15cb8 commit a8c4024

File tree

1 file changed

+97
-53
lines changed

1 file changed

+97
-53
lines changed

apps/site/pages/en/learn/http/enterprise-network-configuration.md

Lines changed: 97 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,42 @@ To override the agent on a per-request basis, use the `agent` option for `http.r
7474
const https = require('node:https');
7575

7676
// Creating a custom agent with custom proxy support.
77-
const agent = new https.Agent({ proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' } });
78-
79-
https.request({
80-
hostname: 'www.external.com',
81-
port: 443,
82-
path: '/',
83-
agent,
84-
}, (res) => {
85-
// This request will be proxied through proxy.company.com:8080 using the HTTP protocol.
77+
const agent = new https.Agent({
78+
proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' },
8679
});
80+
81+
https.request(
82+
{
83+
hostname: 'www.external.com',
84+
port: 443,
85+
path: '/',
86+
agent,
87+
},
88+
res => {
89+
// This request will be proxied through proxy.company.com:8080 using the HTTP protocol.
90+
}
91+
);
8792
```
8893

8994
```mjs
9095
import https from 'node:https';
9196

9297
// Creating a custom agent with custom proxy support.
93-
const agent = new https.Agent({ proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' } });
94-
95-
https.request({
96-
hostname: 'www.external.com',
97-
port: 443,
98-
path: '/',
99-
agent,
100-
}, (res) => {
101-
// This request will be proxied through proxy.company.com:8080 using the HTTP protocol.
98+
const agent = new https.Agent({
99+
proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' },
102100
});
101+
102+
https.request(
103+
{
104+
hostname: 'www.external.com',
105+
port: 443,
106+
path: '/',
107+
agent,
108+
},
109+
res => {
110+
// This request will be proxied through proxy.company.com:8080 using the HTTP protocol.
111+
}
112+
);
103113
```
104114

105115
To override the agent globally, reset `http.globalAgent` and `https.globalAgent`:
@@ -112,24 +122,40 @@ To override the agent globally, reset `http.globalAgent` and `https.globalAgent`
112122
const http = require('node:http');
113123
const https = require('node:https');
114124

115-
http.globalAgent = new http.Agent({ proxyEnv: { HTTP_PROXY: 'http://proxy.company.com:8080' } });
116-
https.globalAgent = new https.Agent({ proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' } });
125+
http.globalAgent = new http.Agent({
126+
proxyEnv: { HTTP_PROXY: 'http://proxy.company.com:8080' },
127+
});
128+
https.globalAgent = new https.Agent({
129+
proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' },
130+
});
117131

118132
// Subsequent requests will all use the configured proxies, unless they override the agent option.
119-
http.request('http://external.com', (res) => { /* ... */ });
120-
https.request('https://external.com', (res) => { /* ... */ });
133+
http.request('http://external.com', res => {
134+
/* ... */
135+
});
136+
https.request('https://external.com', res => {
137+
/* ... */
138+
});
121139
```
122140

123141
```mjs
124142
import http from 'node:http';
125143
import https from 'node:https';
126144

127-
http.globalAgent = new http.Agent({ proxyEnv: { HTTP_PROXY: 'http://proxy.company.com:8080' } });
128-
https.globalAgent = new https.Agent({ proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' } });
145+
http.globalAgent = new http.Agent({
146+
proxyEnv: { HTTP_PROXY: 'http://proxy.company.com:8080' },
147+
});
148+
https.globalAgent = new https.Agent({
149+
proxyEnv: { HTTPS_PROXY: 'http://proxy.company.com:8080' },
150+
});
129151

130152
// Subsequent requests will all use the configured proxies, unless they override the agent option.
131-
http.request('http://external.com', (res) => { /* ... */ });
132-
https.request('https://external.com', (res) => { /* ... */ });
153+
http.request('http://external.com', res => {
154+
/* ... */
155+
});
156+
https.request('https://external.com', res => {
157+
/* ... */
158+
});
133159
```
134160

135161
### Using Proxies with Authentication
@@ -146,13 +172,13 @@ export HTTPS_PROXY=http://username:password@proxy.company.com:8080
146172

147173
The `NO_PROXY` variable supports:
148174

149-
* `*` - Bypass proxy for all hosts
150-
* `company.com` - Exact host name match
151-
* `.company.com` - Domain suffix match (matches `sub.company.com`)
152-
* `*.company.com` - Wildcard domain match
153-
* `192.168.1.100` - Exact IP address match
154-
* `192.168.1.1-192.168.1.100` - IP address range
155-
* `company.com:8080` - Hostname with specific port
175+
- `*` - Bypass proxy for all hosts
176+
- `company.com` - Exact host name match
177+
- `.company.com` - Domain suffix match (matches `sub.company.com`)
178+
- `*.company.com` - Wildcard domain match
179+
- `192.168.1.100` - Exact IP address match
180+
- `192.168.1.1-192.168.1.100` - IP address range
181+
- `company.com:8080` - Hostname with specific port
156182

157183
If a target matches `NO_PROXY`, the request bypasses the proxy.
158184

@@ -218,8 +244,12 @@ const systemCerts = tls.getCACertificates('system');
218244
tls.setDefaultCACertificates([...currentCerts, ...systemCerts]);
219245

220246
// Subsequent requests use system certificates during verification.
221-
https.get('https://internal.company.com', (res) => { /* ... */ });
222-
fetch('https://internal.company.com').then((res) => { /* ... */ });
247+
https.get('https://internal.company.com', res => {
248+
/* ... */
249+
});
250+
fetch('https://internal.company.com').then(res => {
251+
/* ... */
252+
});
223253
```
224254

225255
```mjs
@@ -230,8 +260,12 @@ const systemCerts = tls.getCACertificates('system');
230260
tls.setDefaultCACertificates([...currentCerts, ...systemCerts]);
231261

232262
// Subsequent requests use system certificates during verification.
233-
https.get('https://internal.company.com', (res) => { /* ... */ });
234-
fetch('https://internal.company.com').then((res) => { /* ... */ });
263+
https.get('https://internal.company.com', res => {
264+
/* ... */
265+
});
266+
fetch('https://internal.company.com').then(res => {
267+
/* ... */
268+
});
235269
```
236270

237271
#### Configure CA Certificates for Individual Requests
@@ -241,25 +275,35 @@ To override CA certificates per request, use the `ca` option. This is currently
241275
```cjs
242276
const https = require('node:https');
243277
const specialCerts = ['-----BEGIN CERTIFICATE-----\n...'];
244-
https.get({
245-
hostname: 'internal.company.com',
246-
port: 443,
247-
path: '/',
248-
method: 'GET',
249-
// The `ca` option replaces defaults; concatenate bundled certs if needed.
250-
ca: specialCerts,
251-
}, (res) => { /* ... */ });
278+
https.get(
279+
{
280+
hostname: 'internal.company.com',
281+
port: 443,
282+
path: '/',
283+
method: 'GET',
284+
// The `ca` option replaces defaults; concatenate bundled certs if needed.
285+
ca: specialCerts,
286+
},
287+
res => {
288+
/* ... */
289+
}
290+
);
252291
```
253292

254293
```mjs
255294
import https from 'node:https';
256295
const specialCerts = ['-----BEGIN CERTIFICATE-----\n...'];
257-
https.get({
258-
hostname: 'internal.company.com',
259-
port: 443,
260-
path: '/',
261-
method: 'GET',
262-
// The `ca` option replaces defaults; concatenate bundled certs if needed.
263-
ca: specialCerts,
264-
}, (res) => { /* ... */ });
296+
https.get(
297+
{
298+
hostname: 'internal.company.com',
299+
port: 443,
300+
path: '/',
301+
method: 'GET',
302+
// The `ca` option replaces defaults; concatenate bundled certs if needed.
303+
ca: specialCerts,
304+
},
305+
res => {
306+
/* ... */
307+
}
308+
);
265309
```

0 commit comments

Comments
 (0)