feat: add deno-fetch-auto-proxy-mod.ts

This commit is contained in:
2025-01-19 14:20:51 +08:00
parent 28153b7b83
commit b057454890

View File

@@ -0,0 +1,18 @@
export function getEnvironmentProxy(): string | undefined {
return Deno.env.get("ALL_PROXY") || Deno.env.get("HTTPS_PROXY") ||
Deno.env.get("HTTP_PROXY");
}
export function getFetchAutoProxyInit(): RequestInit | undefined {
const environmentProxy = getEnvironmentProxy();
if (environmentProxy) {
return {
client: Deno.createHttpClient({
proxy: {
url: environmentProxy,
},
}),
} as RequestInit;
}
return undefined;
}