mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Proxy Agent moved to the separate file, Triggers are using proxy now to perform fetch
Summary: - Webhooks form Triggers.ts should now use proxy if it's configured - Proxy handling code separated to ProxyAgent.ts - Tests for ProxyAgent - Integration/API Tests for using Proxy in webhooks - a bit of refactor - proxy test uses mostly the same codebase as DocApi.ts, but because last one if over 4000 lines long, I've put it into separated file, and extract some common parts (there is some duplicates tho) - some cleanup in files that I've touched Test Plan: Manual test to check if proxy is used on the staging env Automatic test checking if (fake) proxy was called Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3860
This commit is contained in:
11
app/server/utils/ProxyAgent.ts
Normal file
11
app/server/utils/ProxyAgent.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user