Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support proxy option #614

Merged
merged 6 commits into from Apr 8, 2024
Merged

feat: Support proxy option #614

merged 6 commits into from Apr 8, 2024

Conversation

danielbankhead
Copy link
Member

Fixes #520
馃

@danielbankhead danielbankhead requested a review from a team as a code owner April 5, 2024 00:44
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 5, 2024
Copy link

Warning: This pull request is touching the following templated files:

Comment on lines +339 to +342
opts.agent = new HttpsProxyAgent(proxy, {
cert: opts.cert,
key: opts.key,
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the following link I do not believe mTLS was working for proxied requests previously:

This was due to HttpsProxyAgent being any at the time

Copy link
Contributor

Choose a reason for hiding this comment

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

Woah, if I'm reading this right how did it work at all? Looks like the first parameter should have been Uri | URL, not an object. Nice catch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep! Never worked at all 馃様

Comment on lines +467 to +485

/**
* A cache for the lazily-loaded proxy agent.
*
* Should use {@link Gaxios[#getProxyAgent]} to retrieve.
*/
// using `import` to dynamically import the types here
static #proxyAgent?: typeof import('https-proxy-agent').HttpsProxyAgent;

/**
* Imports, caches, and returns a proxy agent - if not already imported
*
* @returns A proxy agent
*/
static async #getProxyAgent() {
this.#proxyAgent ||= (await import('https-proxy-agent')).HttpsProxyAgent;

return this.#proxyAgent;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This may have the convenient side-effect of preventing esbuild from automatically pulling this in!

See out.js via:

npx esbuild ./build/src/index.js --platform=node --bundle --outfile=out.js

Related:

@danielbankhead
Copy link
Member Author

Working on some tests.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 6, 2024
@danielbankhead danielbankhead merged commit 2d14b3f into main Apr 8, 2024
15 checks passed
@danielbankhead danielbankhead deleted the support-proxy-config branch April 8, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support proxy option instead of HTTP_PROXY env variable
2 participants