Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1519

Multiple agents in Node.js

$
0
0

Is it possible to use 2 agents when making an HTTP request in Node.js?

I need one agent to use my corporate proxy to access the internet, and I need one more to do the client authentication with a certificate to my endpoint.

This is my agent for the corporate proxy (A worth thing to mention is that my proxy uses the CONNECT method, so just passing the proxy parameter to the request will not work; Also I have an http proxy, but an https endpoint):

import { HttpsProxyAgent } from 'https-proxy-agent';const httpsAgent = new HttpsProxyAgent('http://proxy-host:proxy-port');

This is my agent for passing the certificate:

import https from "https";const pfxPath = "/path/to/my/pfx/file";const passphrase = "myPassphrase";const agent = new https.Agent({  pfx: fs.readFileSync(pfxPath),  passphrase,});

Is there a way to use both agents, or somehow create one that will handle the work for both of them?

I have tried different libraries for making requests such as request, axios, https, etc. ChatGPT wasn't helpful, as well.


Viewing all articles
Browse latest Browse all 1519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>