Files
hyperframes/packages/core/src/envProxy.ts
T
Miguel Ángel 9830059bdb fix(engine): downloads refuse hosts that resolve to private addresses (#6571)
* fix(engine): downloads refuse hosts that resolve to private addresses

* fix(core): shorten the env proxy doc comment

* test(producer): remote-media tests stub the download fetch seam
2026-10-28 20:08:50 +00:00

19 lines
760 B
TypeScript

/** Whether `fetch` follows the proxy variables (`NODE_USE_ENV_PROXY=1` or `--use-env-proxy`). */
export function envProxyEnabled(
env: NodeJS.ProcessEnv = process.env,
execArgv: readonly string[] = process.execArgv,
): boolean {
const flags = [...execArgv, ...(env["NODE_OPTIONS"]?.split(/\s+/u) ?? [])];
return env["NODE_USE_ENV_PROXY"] === "1" || flags.includes("--use-env-proxy");
}
/** Whether `fetch` reaches the network through `HTTPS_PROXY`, which then does the name resolution. */
export function fetchGoesThroughEnvProxy(
env: NodeJS.ProcessEnv = process.env,
execArgv: readonly string[] = process.execArgv,
): boolean {
return (
Boolean((env["HTTPS_PROXY"] ?? env["https_proxy"])?.trim()) && envProxyEnabled(env, execArgv)
);
}