ProxyAgent configure requestTls per origin #3186
-
👋 Hello. When using the Agent, I can configure it as a global dispatcher such that it can pass client certificates to origins that require it. For example, setGlobalDispatcher(new Agent({
factory(origin, opts) {
if (origin === 'mysecureapi.com') {
opts.connect = {
cert: '...',
key: '...'
};
}
return new Pool(origin, opts);
}
}));
// Doesn't pass the client cert ✅
undici.request('https://otherapi.com/foo', ...);
// Passes the client cert ✅
undici.request('https://mysecureapi.com/baz', ...); Now let's suppose I want to replace the global dispatcher above with a ProxyAgent. I'm not seeing a way to set it up so that only requests to mysecureapi.com have a client cert sent, because it doesn't look like the Is there anything I'm misunderstanding with how ProxyAgent is intended to be used, or is this just a new feature to be added? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
The The strategy should be similar as the example you shared |
Beta Was this translation helpful? Give feedback.
Ah got it now, see what you are trying to achieve.
Yeah, the short answer is that it cannot be done in that way; you can have two different ProxyAgents set and used on the
Agent#factory
that alters this based on the origin you are looking for, but currently, ProxyAgent does not support that level of granularity.But I see a potential use case there that will be worth it to explore, would you like to open a PR for it?