-
Notifications
You must be signed in to change notification settings - Fork 276
Doesn't seem to pass options to tls.connect #89
Copy link
Copy link
Closed
Description
as per documentation https://www.npmjs.com/package/https-proxy-agent#new-httpsproxyagentobject-options
- Any other options given are passed to the net.connect()/tls.connect() functions.
But when I try this, it doesn't seem to pass ca or rejectUnauthorized when upgrading connection. I can get around it by monkey patching the agent callback:
const HttpsProxyAgent = require('https-proxy-agent');
const fetch = require('node-fetch')
const extraOpts = Symbol('extra agent opts');
class PatchedHttpsProxyAgent extends HttpsProxyAgent {
constructor (opts) {
super(opts);
this[extraOpts] = opts;
}
callback (req, opts, fn) {
return super.callback(req, { ...this[extraOpts], ...opts }, fn);
}
}
async function main () {
const res = await fetch('https://my-url', {
agent: new PatchedHttpsProxyAgent({
protocol: 'http:',
host: 'my-proxy',
rejectUnauthorized: false
})
});
console.log(res.status);
}
main();I feel like this could be solved by changing this line https://github.com/TooTallNate/node-https-proxy-agent/blob/176d4b4fb20e229cf6cd1008f06bf97833fd725f/index.js#L151
to
sock = tls.connect({ ...proxy, ...opts });so that all input options are passed when upgrading.
What do you think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels