12 lines
415 B
TypeScript
12 lines
415 B
TypeScript
// @ts-nocheck
|
|
import { ProxyAgent } from "undici";
|
|
import { wrapFetchWithAbortSignal } from "../infra/fetch.js";
|
|
|
|
export function makeProxyFetch(proxyUrl: string): typeof fetch {
|
|
const agent = new ProxyAgent(proxyUrl);
|
|
return wrapFetchWithAbortSignal((input: RequestInfo | URL, init?: RequestInit) => {
|
|
const base = init ? { ...init } : {};
|
|
return fetch(input, { ...base, dispatcher: agent });
|
|
});
|
|
}
|