-
Notifications
You must be signed in to change notification settings - Fork 60
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support proxy
option
#614
Conversation
Warning: This pull request is touching the following templated files:
|
opts.agent = new HttpsProxyAgent(proxy, { | ||
cert: opts.cert, | ||
key: opts.key, | ||
}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😔
|
||
/** | ||
* 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; | ||
} |
There was a problem hiding this comment.
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:
Working on some tests. |
Fixes #520
🦕