Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
91dda5f
deps: update undici to 6.22.0
mcollina Oct 7, 2025
7e0e86c
deps: upgrade npm to 10.9.4
npm-cli-bot Oct 7, 2025
99ea08d
repl: add isValidParentheses check before wrap input
meixg Oct 7, 2025
2237142
module: link module with a module request record
legendecas Oct 7, 2025
7a91282
src: use simdjson::pad
0hmX Aug 17, 2025
6021c3a
tools: copyedit `build-tarball.yml`
aduh95 Sep 10, 2025
ec5290f
build: do not include custom ESLint rules testing in tarball
aduh95 Sep 8, 2025
b632a1d
tools: skip test-internet workflow for draft PRs
targos Sep 11, 2025
d2a7057
lib,src: refactor assert to load error source from memory
legendecas Sep 2, 2025
12e5535
lib: add source map support for assert messages
legendecas Sep 3, 2025
bb6fd7c
src: ensure `v8::Eternal` is empty before setting it
addaleax Sep 11, 2025
9833dc6
doc: rephrase dynamic import() description
meteorqz6 Sep 12, 2025
24c2249
url: add type checking to urlToHttpOptions()
simon-id Sep 12, 2025
16c4b46
benchmark: calibrate config cluster/echo.js
meteorqz6 Sep 12, 2025
4cc84c9
node-api: make napi_delete_reference use node_api_basic_env
JeetuSuthar Sep 12, 2025
4d748ad
src: remove `std::array` overload of `FIXED_ONE_BYTE_STRING`
addaleax Aug 4, 2025
34dcb7d
src: create strings in `FIXED_ONE_BYTE_STRING` as internalized
addaleax Aug 4, 2025
e790eb6
repl: fix cpu overhead pasting big strings to the REPL
BridgeAR Sep 14, 2025
f2fbcc5
util: fix debuglog.enabled not being present with callback logger
BridgeAR Sep 14, 2025
8fd669c
doc: type improvement of file `http.md`
samuel871211 Sep 14, 2025
f88752d
url: replaced slice with at
Connormiha Sep 14, 2025
a71dd59
benchmark: calibrate config dgram multi-buffer
brunocroh Sep 14, 2025
758271a
http: optimize checkIsHttpToken for short strings
JinhyeokFang Sep 14, 2025
a33ed9b
inspector: ensure adequate memory allocation for `Binary::toBase64`
Renegade334 Sep 14, 2025
0a3a3f7
doc: add security escalation policy
UlisesGascon Sep 15, 2025
28ef564
typings: remove unused imports
meteorqz6 Sep 15, 2025
6d24b88
node-api: added SharedArrayBuffer api
mertcanaltin Sep 16, 2025
ba00875
stream: use new AsyncResource instead of bind
mcollina Sep 16, 2025
26b40ba
src: replace FIXED_ONE_BYTE_STRING with Environment-cached strings
iknoom Sep 17, 2025
36b68db
src: reduce the nearest parent package JSON cache size
michaelsmithxyz Sep 17, 2025
85818db
fs,win: do not add a second trailing slash in readdir
Flarna Sep 17, 2025
c42c120
tools: fix `tools/make-v8.sh` for clang
richardlau Sep 17, 2025
af8b5fa
http: add shouldUpgradeCallback to let servers control HTTP upgrades
pimterry Sep 17, 2025
2bf0a93
meta: add .npmrc with ignore-scripts=true
joyeecheung Sep 17, 2025
e02a562
deps: upgrade openssl sources to openssl-3.5.3
nodejs-github-bot Sep 16, 2025
48aaf98
deps: update archs files for openssl-3.5.3
nodejs-github-bot Sep 16, 2025
09bdcce
diagnostics_channel: fix race condition with diagnostics_channel and GC
uurien Sep 19, 2025
892b425
src: rename private fields to follow naming convention
iknoom Sep 20, 2025
c9cde35
src: simplify is_callable by making it a concept
tniessen Sep 20, 2025
34c686b
lib: update inspect output format for subclasses
miguelmarcondesf Sep 21, 2025
ca1942c
test: testcase demonstrating issue 59541
ericrannaud Sep 7, 2025
312b33a
vm: "afterEvaluate", evaluate() return a promise from the outer context
ericrannaud Sep 10, 2025
5bf21a4
vm: explain how to share promises between contexts w/ afterEvaluate
ericrannaud Sep 19, 2025
3a3220a
dgram: restore buffer optimization in fixBufferList
ri7116 Sep 21, 2025
d6e303d
doc: update V8 fast API guidance
Renegade334 Sep 21, 2025
53cb9f3
build: add the missing macro definitions for OpenHarmony
hqzing Sep 22, 2025
816e1be
zlib: reduce code duplication
jhofstee Sep 22, 2025
badbba2
deps: update googletest to 50b8600
nodejs-github-bot Sep 23, 2025
4808dbd
doc: fix typo in section on microtask order
tniessen Sep 23, 2025
4bc366f
doc: use "WebAssembly" instead of "Web Assembly"
tniessen Sep 24, 2025
8e182e5
src: remove unnecessary `Environment::GetCurrent()` calls
iknoom Sep 11, 2025
aed9fd5
crypto: avoid calls to `promise.catch()`
Renegade334 Sep 9, 2025
f488b2f
crypto: use async functions for non-stub Promise-returning functions
Renegade334 Sep 9, 2025
1f93913
crypto: use `return await` when returning Promises from async functions
Renegade334 Sep 9, 2025
2870a73
doc,crypto: update subtle.generateKey and subtle.importKey
panva Sep 13, 2025
095e7a8
tls: only do off-thread certificate loading on loading tls
joyeecheung Sep 11, 2025
19a7b1e
tls: load bundled and extra certificates off-thread
joyeecheung Sep 11, 2025
e4a4f63
sqlite: fix crash session extension callbacks with workers
louwers Sep 23, 2025
ddbc1aa
deps: upgrade openssl sources to openssl-3.5.4
nodejs-github-bot Oct 1, 2025
28aea13
deps: update archs files for openssl-3.5.4
nodejs-github-bot Oct 1, 2025
37c2d18
deps: update amaro to 1.1.4
pmarchini Sep 29, 2025
04590b8
meta: bump actions/setup-python from 5.6.0 to 6.0.0
dependabot[bot] Oct 5, 2025
0fedbb3
meta: bump ossf/scorecard-action from 2.4.2 to 2.4.3
dependabot[bot] Oct 4, 2025
1f3b9d6
meta: bump actions/cache from 4.2.4 to 4.3.0
dependabot[bot] Oct 4, 2025
7cd2b42
meta: bump step-security/harden-runner from 2.12.2 to 2.13.1
dependabot[bot] Oct 4, 2025
0feca0c
meta: bump actions/setup-node from 4.4.0 to 5.0.0
dependabot[bot] Oct 4, 2025
a0ba688
meta: bump actions/stale from 9.1.0 to 10.0.0
dependabot[bot] Oct 4, 2025
090ba14
meta: bump codecov/codecov-action from 5.5.0 to 5.5.1
dependabot[bot] Oct 3, 2025
c591cca
meta: bump github/codeql-action from 3.30.0 to 3.30.5
dependabot[bot] Oct 3, 2025
20a9e86
meta: move Michael to emeritus
mhdawson Oct 1, 2025
3fca564
doc: add automated migration info to deprecations
AugustinMauroy Oct 6, 2025
ca2dff6
doc: fix typo on child_process.md
nglgzz Oct 6, 2025
d37f67d
doc: remove optional title prefixes
avivkeller Oct 5, 2025
3b3b71e
doc: mark `.env` files support as stable
Hilzu Oct 3, 2025
1ddaab1
doc: mention reverse proxy and include simple example
styfle Sep 4, 2025
b3eeb3b
doc: provide alternative to `url.parse()` using WHATWG URL
styfle Sep 2, 2025
ef005d0
typings: update 'types' binding
Renegade334 Sep 24, 2025
84701ff
src: clear all linked module caches once instantiated
legendecas Jul 29, 2025
e10dc7b
module: allow overriding linked requests for a ModuleWrap
legendecas Aug 22, 2025
6277058
vm: sync-ify SourceTextModule linkage
legendecas Aug 29, 2025
1eadab8
win,tools: add description to signature
martincostello Oct 3, 2025
7067d79
test: mark sea tests flaky on macOS x64
richardlau Sep 30, 2025
686ac49
src: add percentage support to --max-old-space-size
Asaf-Federman Jul 28, 2025
42c5544
src: assert memory calc for max-old-space-size-percentage
Asaf-Federman Aug 18, 2025
660d573
test,doc: skip --max-old-space-size-percentage on 32-bit platforms
Asaf-Federman Oct 9, 2025
bedaaa1
http: support http proxy for fetch under NODE_USE_ENV_PROXY
joyeecheung Mar 20, 2025
ebec3ef
test: move http proxy tests to test/client-proxy
joyeecheung Jul 3, 2025
4210259
http,https: add built-in proxy support in http/https.request and Agent
joyeecheung Jul 1, 2025
1486fed
cli: add --use-env-proxy
joyeecheung Jul 26, 2025
54b94e1
2025-10-20, Version 22.21.0 'Jod' (LTS)
aduh95 Oct 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
http: support http proxy for fetch under NODE_USE_ENV_PROXY
When enabled, Node.js parses the `HTTP_PROXY`, `HTTPS_PROXY` and
`NO_PROXY` environment variables during startup, and tunnels requests
over the specified proxy.

This currently only affects requests sent over `fetch()`. Support for
other built-in `http` and `https` methods is under way.

PR-URL: #57165
Refs: nodejs/undici#1650
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
joyeecheung authored and aduh95 committed Oct 18, 2025
commit bedaaa11fc07ee220e6dde457050c2dbb4931ace
15 changes: 15 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,21 @@ If `value` equals `'0'`, certificate validation is disabled for TLS connections.
This makes TLS, and HTTPS by extension, insecure. The use of this environment
variable is strongly discouraged.

### `NODE_USE_ENV_PROXY=1`

<!-- YAML
added: REPLACEME
-->

> Stability: 1.1 - Active Development
When enabled, Node.js parses the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`
environment variables during startup, and tunnels requests over the
specified proxy.

This currently only affects requests sent over `fetch()`. Support for other
built-in `http` and `https` methods is under way.

### `NODE_USE_SYSTEM_CA=1`

<!-- YAML
Expand Down
13 changes: 13 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,19 @@ When set to
.Ar 0 ,
TLS certificate validation is disabled.
.
.It Ev NODE_USE_ENV_PROXY
When enabled, Node.js parses the
.Ar HTTP_PROXY
,
.Ar HTTPS_PROXY
and
.Ar NO_PROXY
environment variables during startup, and tunnels requests over the specified proxy.
.Pp
This currently only affects requests sent over
.Ar fetch() .
Support for other built-in http and https methods is under way.
.
.It Ev NODE_USE_SYSTEM_CA
Similar to
.Fl -use-system-ca .
Expand Down
16 changes: 16 additions & 0 deletions lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function prepareExecution(options) {
initializeConfigFileSupport();

require('internal/dns/utils').initializeDns();
setupHttpProxy();

setupSymbolDisposePolyfill();

Expand Down Expand Up @@ -189,6 +190,21 @@ function setupSymbolDisposePolyfill() {
}
}

function setupHttpProxy() {
if (process.env.NODE_USE_ENV_PROXY &&
(process.env.HTTP_PROXY || process.env.HTTPS_PROXY ||
process.env.http_proxy || process.env.https_proxy)) {
const { setGlobalDispatcher, EnvHttpProxyAgent } = require('internal/deps/undici/undici');
const envHttpProxyAgent = new EnvHttpProxyAgent();
setGlobalDispatcher(envHttpProxyAgent);
// TODO(joyeecheung): This currently only affects fetch. Implement handling in the
// http/https Agent constructor too.
// TODO(joyeecheung): This is currently guarded with NODE_USE_ENV_PROXY. Investigate whether
// it's possible to enable it by default without stepping on other existing libraries that
// sets the global dispatcher or monkey patches the global agent.
}
}

function setupUserModules(forceDefaultLoader = false) {
initializeCJSLoader();
initializeESMLoader(forceDefaultLoader);
Expand Down
100 changes: 100 additions & 0 deletions test/common/proxy-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use strict';

const net = require('net');
const http = require('http');
const assert = require('assert');

function logRequest(logs, req) {
logs.push({
method: req.method,
url: req.url,
headers: { ...req.headers },
});
}

// This creates a minimal proxy server that logs the requests it gets
// to an array before performing proxying.
exports.createProxyServer = function() {
const logs = [];

const proxy = http.createServer();
proxy.on('request', (req, res) => {
logRequest(logs, req);
const [hostname, port] = req.headers.host.split(':');
const targetPort = port || 80;

const options = {
hostname: hostname,
port: targetPort,
path: req.url,
method: req.method,
headers: req.headers,
};

const proxyReq = http.request(options, (proxyRes) => {
res.writeHead(proxyRes.statusCode, proxyRes.headers);
proxyRes.pipe(res, { end: true });
});

proxyReq.on('error', (err) => {
logs.push({ error: err, source: 'proxy request' });
res.writeHead(500);
res.end('Proxy error: ' + err.message);
});

req.pipe(proxyReq, { end: true });
});

proxy.on('connect', (req, res, head) => {
logRequest(logs, req);

const [hostname, port] = req.url.split(':');
const proxyReq = net.connect(port, hostname, () => {
res.write(
'HTTP/1.1 200 Connection Established\r\n' +
'Proxy-agent: Node.js-Proxy\r\n' +
'\r\n',
);
proxyReq.write(head);
res.pipe(proxyReq);
proxyReq.pipe(res);
});

proxyReq.on('error', (err) => {
logs.push({ error: err, source: 'proxy request' });
res.write('HTTP/1.1 500 Connection Error\r\n\r\n');
res.end('Proxy error: ' + err.message);
});
});

proxy.on('error', (err) => {
logs.push({ error: err, source: 'proxy server' });
});

return { proxy, logs };
};

exports.checkProxiedRequest = async function(envExtension, expectation) {
const { spawnPromisified } = require('./');
const fixtures = require('./fixtures');
const { code, signal, stdout, stderr } = await spawnPromisified(
process.execPath,
['--no-warnings', fixtures.path('fetch-and-log.mjs')], {
env: {
...process.env,
...envExtension,
},
});

assert.deepStrictEqual({
stderr: stderr.trim(),
stdout: stdout.trim(),
code,
signal,
}, {
stderr: '',
code: 0,
signal: null,
...expectation,
});
};
3 changes: 3 additions & 0 deletions test/fixtures/fetch-and-log.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const response = await fetch(process.env.FETCH_URL);
const body = await response.text();
console.log(body);
61 changes: 61 additions & 0 deletions test/parallel/test-http-proxy-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const { once } = require('events');
const http = require('http');
const { createProxyServer, checkProxiedRequest } = require('../common/proxy-server');

(async () => {
// Start a server to process the final request.
const server = http.createServer(common.mustCall((req, res) => {
res.end('Hello world');
}, 2));
server.on('error', common.mustNotCall((err) => { console.error('Server error', err); }));
server.listen(0);
await once(server, 'listening');

// Start a minimal proxy server.
const { proxy, logs } = createProxyServer();
proxy.listen(0);
await once(proxy, 'listening');

const serverHost = `localhost:${server.address().port}`;

// FIXME(undici:4083): undici currently always tunnels the request over
// CONNECT, no matter it's HTTP traffic or not, which is different from e.g.
// how curl behaves.
const expectedLogs = [{
method: 'CONNECT',
url: serverHost,
headers: {
// FIXME(undici:4086): this should be keep-alive.
connection: 'close',
host: serverHost
}
}];

// Check upper-cased HTTPS_PROXY environment variable.
await checkProxiedRequest({
NODE_USE_ENV_PROXY: 1,
FETCH_URL: `http://${serverHost}/test`,
HTTP_PROXY: `http://localhost:${proxy.address().port}`,
}, {
stdout: 'Hello world',
});
assert.deepStrictEqual(logs, expectedLogs);

// Check lower-cased https_proxy environment variable.
logs.splice(0, logs.length);
await checkProxiedRequest({
NODE_USE_ENV_PROXY: 1,
FETCH_URL: `http://${serverHost}/test`,
http_proxy: `http://localhost:${proxy.address().port}`,
}, {
stdout: 'Hello world',
});
assert.deepStrictEqual(logs, expectedLogs);

proxy.close();
server.close();
})().then(common.mustCall());
67 changes: 67 additions & 0 deletions test/parallel/test-https-proxy-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const fixtures = require('../common/fixtures');
const assert = require('assert');
const https = require('https');
const { once } = require('events');
const { createProxyServer, checkProxiedRequest } = require('../common/proxy-server');

(async () => {
// Start a server to process the final request.
const server = https.createServer({
cert: fixtures.readKey('agent8-cert.pem'),
key: fixtures.readKey('agent8-key.pem'),
}, common.mustCall((req, res) => {
res.end('Hello world');
}, 2));
server.on('error', common.mustNotCall((err) => { console.error('Server error', err); }));
server.listen(0);
await once(server, 'listening');

// Start a minimal proxy server.
const { proxy, logs } = createProxyServer();
proxy.listen(0);
await once(proxy, 'listening');

const serverHost = `localhost:${server.address().port}`;

const expectedLogs = [{
method: 'CONNECT',
url: serverHost,
headers: {
// FIXME(undici:4086): this should be keep-alive.
connection: 'close',
host: serverHost
}
}];

// Check upper-cased HTTPS_PROXY environment variable.
await checkProxiedRequest({
NODE_USE_ENV_PROXY: 1,
FETCH_URL: `https://${serverHost}/test`,
HTTPS_PROXY: `http://localhost:${proxy.address().port}`,
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'fake-startcom-root-cert.pem'),
}, {
stdout: 'Hello world',
});
assert.deepStrictEqual(logs, expectedLogs);

// Check lower-cased https_proxy environment variable.
logs.splice(0, logs.length);
await checkProxiedRequest({
NODE_USE_ENV_PROXY: 1,
FETCH_URL: `https://${serverHost}/test`,
https_proxy: `http://localhost:${proxy.address().port}`,
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'fake-startcom-root-cert.pem'),
}, {
stdout: 'Hello world',
});
assert.deepStrictEqual(logs, expectedLogs);

proxy.close();
server.close();
})().then(common.mustCall());