undici
undici copied to clipboard
ProxyAgent support proxy as URL
why not add proxy support as a URL?
import { env } from "./env.mjs";
import { ProxyAgent } from "undici";
// env.PROXY_URL = 'http://username:password@ip:port';
const proxy = new URL(env.PROXY_URL);
// WORK
export const proxyAgent = new ProxyAgent({
uri: proxy.origin + proxy.pathname,
token: `Basic ${Buffer.from(`${proxy.username}:${proxy.password}`).toString('base64')}`,
});
// DONT WORK
export const proxyAgent2 = new ProxyAgent(proxy);
I'm open to supporting both. But let's make sure it doesn't impact performance for the ProxyAgent instantiation.
AFAIK we are looking to deprecate the simple auth method in favor of token based one. Adding support for it might mean we are going against the deprecation.
If the deprecation is something we want to fully remove support for in the next major, I think we shouldn’t add support for it. Otherwise, happy to add support for it.
On a side note, I believe that adding support for
URL
instances seems beneficial though
cc. @ronag @mcollina
99% of proxies use basic authorization. This won't affect anything. Through the parameters it will be possible to specify an explicit authorization type, if it is not basic
Hmm, never mind, I take back what I said; I read the deprecation wrongly. Basically is just about deprecating property auth
in favour of token
(sorry about that).
Then, no issue at all; then SGTM adding support for object URL
support
Since #2810 has been merged, can this be closed?
Yep