mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
12 lines
420 B
TypeScript
12 lines
420 B
TypeScript
|
import {HttpsProxyAgent} from "https-proxy-agent";
|
||
|
import {HttpProxyAgent} from "http-proxy-agent";
|
||
|
|
||
|
export function proxyAgent(requestUrl: URL): HttpProxyAgent | HttpsProxyAgent | undefined {
|
||
|
const proxy = process.env.GRIST_HTTPS_PROXY;
|
||
|
if (!proxy) {
|
||
|
return undefined;
|
||
|
}
|
||
|
const ProxyAgent = requestUrl.protocol === "https:" ? HttpsProxyAgent : HttpProxyAgent;
|
||
|
return new ProxyAgent(proxy);
|
||
|
}
|