Skip to content

feat: add upstream proxy configuration for outbound requests#1458

Open
Andreybest wants to merge 6 commits intofinos:mainfrom
Andreybest:759-upstream-proxy
Open

feat: add upstream proxy configuration for outbound requests#1458
Andreybest wants to merge 6 commits intofinos:mainfrom
Andreybest:759-upstream-proxy

Conversation

@Andreybest
Copy link
Copy Markdown

Resolves #759.

Adds upstream proxy support. Uses values from both configuration file in upstreamProxy fields and environment variables (HTTPS_PROXY/HTTP_PROXY, NO_PROXY)

@Andreybest Andreybest requested a review from a team as a code owner March 16, 2026 03:17
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 16, 2026

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 9af1d69
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/69d5cb4e306f0a00071fb9e5

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 16, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@Andreybest Andreybest requested a review from kriswest March 16, 2026 03:17
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 89.87342% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.67%. Comparing base (c0b4a8d) to head (9af1d69).

Files with missing lines Patch % Lines
src/proxy/routes/index.ts 90.27% 7 Missing ⚠️
src/config/index.ts 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1458   +/-   ##
=======================================
  Coverage   89.66%   89.67%           
=======================================
  Files          68       68           
  Lines        4869     4947   +78     
  Branches      888      918   +30     
=======================================
+ Hits         4366     4436   +70     
- Misses        485      493    +8     
  Partials       18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@jescalada jescalada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andreybest Thanks for the contribution! 🚀

I left some comments for code refactoring. It'd be very helpful if you could upload images or a video demonstrating that this feature works as intended.

@coopernetes Wondering if this implements your original requirements (#759) and works on your end 🤔

Copy link
Copy Markdown
Contributor

@dcoric dcoric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling #759. I've left a few comments focused on correctness and robustness, especially around NO_PROXY pattern handling which is important to get right for the target use case. The main items are the missing */leading-dot NO_PROXY support and proxy URL validation.

return undefined;
}

return new HttpsProxyAgent(proxyUrl);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxyUrl (from config or env vars) is passed directly to new HttpsProxyAgent(proxyUrl) without validation. If the URL is malformed (typo, missing protocol, empty string after trimming), this throws a cryptic Invalid URL error that surfaces through express-http-proxy's error handler with no indication that the upstream proxy config is the problem.

Consider wrapping this in a try-catch or validating first:

try {
  new URL(proxyUrl); // validate before constructing agent
} catch {
  throw new Error(`Invalid upstream proxy URL: check your upstreamProxy.url config or HTTPS_PROXY env var`);
}
return new HttpsProxyAgent(proxyUrl);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment might still need fixing! 🙂

@Andreybest
Copy link
Copy Markdown
Author

Thanks for the reviews @jescalada and @dcoric!
Made changes and left comments for your comments. Please recheck :)

@Andreybest
Copy link
Copy Markdown
Author

@jescalada
Here is the video on how the proxy works:

Screen.Recording.2026-03-25.at.21.35.35_no_audio.mov

Co-authored-by: Thomas Cooper <57812123+coopernetes@users.noreply.github.com>
Signed-off-by: Andrew <andrey255@live.com>
Copy link
Copy Markdown
Contributor

@jescalada jescalada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after fixing Denis' comment about validating/error handling the HttpsProxyAgent creation.

@coopernetes Does everything work as you expected? 🤔


const getOrCreateProxyAgent = (proxyUrl: string): HttpsProxyAgent<string> => {
if (!_cachedProxyAgent || _cachedProxyAgent.proxyUrl !== proxyUrl) {
_cachedProxyAgent = { proxyUrl, agent: new HttpsProxyAgent(proxyUrl) };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just repeating Denis earlier comment - this should be properly validated and/or throw a descriptive error

return undefined;
}

return new HttpsProxyAgent(proxyUrl);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment might still need fixing! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose proxy support within GitProxy itself for air gapped environments

5 participants