fix: respect no proxy directive (#1037)

Closes #1034
This commit is contained in:
marcel
2026-09-10 20:40:43 +02:00
committed by GitHub
parent 421feb646d
commit b90ec40d15
3 changed files with 52 additions and 84 deletions
+6 -16
View File
@@ -1,18 +1,8 @@
import { ProxyAgent, type RequestInit, fetch as undiciFetch } from "undici";
export function getProxyAgent() {
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
if (httpProxy) {
return new ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new ProxyAgent(httpsProxy);
}
return undefined;
}
import {
EnvHttpProxyAgent,
type RequestInit,
fetch as undiciFetch,
} from "undici";
export const fetch = async (url: string, opts: RequestInit) => {
// Merge timeout signal with any existing signal from opts
@@ -23,7 +13,7 @@ export const fetch = async (url: string, opts: RequestInit) => {
: timeoutSignal;
return await undiciFetch(url, {
dispatcher: getProxyAgent(),
dispatcher: new EnvHttpProxyAgent(),
...opts,
signal: mergedSignal,
});