undici icon indicating copy to clipboard operation
undici copied to clipboard

ProxyAgent support proxy as URL

Open PandaWorker opened this issue 1 year ago • 4 comments

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);

PandaWorker avatar Sep 21 '23 10:09 PandaWorker

I'm open to supporting both. But let's make sure it doesn't impact performance for the ProxyAgent instantiation.

Ethan-Arrowood avatar Sep 21 '23 17:09 Ethan-Arrowood

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

metcoder95 avatar Sep 21 '23 18:09 metcoder95

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

PandaWorker avatar Sep 21 '23 19:09 PandaWorker

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

metcoder95 avatar Sep 21 '23 21:09 metcoder95

Since #2810 has been merged, can this be closed?

rossilor95 avatar Mar 01 '24 14:03 rossilor95

Yep

Uzlopak avatar Mar 01 '24 14:03 Uzlopak