mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
This adds an API to dynamically enable built-in proxy support for all of fetch() and http.request()/https.request(), so that users do not have to be aware of them all and configure them one by one. PR-URL: https://github.com/nodejs/node/pull/60953 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com>
24 lines
632 B
JavaScript
24 lines
632 B
JavaScript
// Tests that http.setGlobalProxyFromEnv() works with no_proxy configuration.
|
|
|
|
import '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
import { startTestServers, checkProxiedRequest } from '../common/proxy-server.js';
|
|
const { proxyLogs, shutdown, proxyUrl, httpEndpoint: { requestUrl } } = await startTestServers({
|
|
httpEndpoint: true,
|
|
});
|
|
|
|
await checkProxiedRequest({
|
|
REQUEST_URL: requestUrl,
|
|
SET_GLOBAL_PROXY: JSON.stringify({
|
|
http_proxy: proxyUrl,
|
|
no_proxy: 'localhost',
|
|
}),
|
|
}, {
|
|
stdout: 'Hello world',
|
|
});
|
|
|
|
shutdown();
|
|
|
|
// Verify request did NOT go through proxy.
|
|
assert.deepStrictEqual(proxyLogs, []);
|