feat: add deno-fetch-auto-proxy-mod.ts
This commit is contained in:
18
libraries/deno-fetch-auto-proxy-mod.ts
Normal file
18
libraries/deno-fetch-auto-proxy-mod.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user