Use EnvHttpProxyAgent when the process environment should choose the route. Use an explicit Undici ProxyAgent instead when the endpoint should belong to the client configuration. Attach it to the actual request; constructing the agent alone changes no fetch call:

import { EnvHttpProxyAgent, fetch } from 'undici';

const dispatcher = new EnvHttpProxyAgent();

try {
  const response = await fetch("https://example.com/", {
    dispatcher,
    signal: AbortSignal.timeout(15000),
  });
  console.log(response.status);
  await response.arrayBuffer();
} finally {
  await dispatcher.close();
}

Save this as proxy-check.mjs in an ES-module setup with Undici available. A POSIX launch supplies the two proxy routes and an empty bypass list:

http_proxy=http://203.0.113.10:8080 \
https_proxy=http://203.0.113.10:8080 \
no_proxy= \
node proxy-check.mjs

Replace the documentation endpoint with your HTTP proxy or a candidate from the HTTP proxy list. The assignments belong to this invocation; other shells use different syntax.

In Undici 8.12.3, lowercase http_proxy, https_proxy and no_proxy take precedence over uppercase counterparts when both coexist. HTTP and HTTPS destinations select their own settings. An HTTP-only setting also supplies HTTPS fallback; an HTTPS-only setting does not supply HTTP. Do not assume another client's ALL_PROXY convention applies.

InputWhen this release uses it
HTTP/HTTPS proxy environmentChosen during agent construction. Create a new dispatcher after changing those endpoints.
Environment no_proxyChecked again as requests are dispatched.
Constructor noProxyFixes bypass policy explicitly instead of following later environment changes.

Bypasses can match hosts and optional ports; a single asterisk bypasses every request. Inspect the destination match if the proxy sees no traffic.

On Windows, the main process treats environment names case-insensitively, so HTTP_PROXY and http_proxy are not independent values. Node Worker environment copies have a documented case-sensitive distinction. Account for that before testing precedence by setting both spellings. The example closes its dispatcher after the workload; retain it while repeated requests need the same captured endpoint policy.

Аффингæй хæстæг статьялтæ