Merge pull request #726 from Kherrisan/main

feat: add support for setting the global fetch proxy through HTTP_PROXY
This commit is contained in:
Kai (Tam Nhu) Tran authored and GitHub committed 2026-03-16 07:20:48 -04:00
commit 3c7c8d5573
10 files changed
+656 -50

No files matched your search

@@ -68,6 +68,12 @@ describe('Binary Downloader Proxy Support', () => {
process.env.ALL_PROXY = 'http://allproxy:8080';
expect(getProxyUrl(true)).toBe('http://allproxy:8080');
});
it('should skip invalid HTTP_PROXY and fall back to ALL_PROXY', () => {
process.env.HTTP_PROXY = 'not-a-valid-url';
process.env.ALL_PROXY = 'http://allproxy:8080';
expect(getProxyUrl(true)).toBe('http://allproxy:8080');
});
});
describe('HTTP requests', () => {
@@ -91,6 +97,12 @@ describe('Binary Downloader Proxy Support', () => {
expect(getProxyUrl(false)).toBe('http://allproxy:8080');
});
it('should skip invalid HTTP_PROXY and use ALL_PROXY for HTTP', () => {
process.env.HTTP_PROXY = 'not-a-valid-url';
process.env.ALL_PROXY = 'http://allproxy:8080';
expect(getProxyUrl(false)).toBe('http://allproxy:8080');
});
it('should not use https_proxy for HTTP requests', () => {
process.env.https_proxy = 'http://httpsproxy:8080';
expect(getProxyUrl(false)).toBeUndefined();
@@ -251,6 +263,11 @@ describe('Binary Downloader Proxy Support', () => {
expect(getProxyAgent('https://example.com')).toBe(false);
});
it('should keep supporting socks proxy URLs for downloader traffic', () => {
process.env.https_proxy = 'socks5://proxy:1080';
expect(getProxyAgent('https://example.com')).not.toBe(false);
});
it('should return false for invalid target URL', () => {
process.env.https_proxy = 'http://proxy:8080';
expect(getProxyAgent('not-a-url')).toBe(false);