Files
triggerdotdev--trigger.dev/packages/cli/src/utils/fetchUseProxy.ts
T
arika 7833db45d7 feat: add proxy support to the CLI (#404)
* feat: add proxy support for node-fetch

This process is expected to allow the CLI and SDK to work in environments where proxy is enabled.

* Revert "feat: add proxy support for node-fetch"

This reverts commit c850030b5927c562921409fc5b798af353a7ac6b.

* feat: add proxy support for node-fetch (CLI only)

---------

Co-authored-by: Matt Aitken <matt@mattaitken.com>
2023-09-11 13:56:55 +01:00

17 lines
546 B
TypeScript

import node_fetch, { RequestInfo as _RequestInfo, RequestInit as _RequestInit } from "node-fetch";
import { ProxyAgent } from "proxy-agent";
export type RequestInfo = _RequestInfo;
export type RequestInit = _RequestInit;
export default function fetch(url: RequestInfo, init?: RequestInit) {
const fetchInit: RequestInit = { ...init };
// If agent is not specified, specify proxy-agent and use environment variables such as HTTPS_PROXY.
if (!fetchInit.agent) {
fetchInit.agent = new ProxyAgent();
}
return node_fetch(url, fetchInit);
}