Bug Description
I was expecting the classic behavior of passing a proxy URL to be parsed apart. However, ProxyAgent ignores the auth part.
Reproducible By
import { ProxyAgent, request } from 'undici';
const PROXY_URL = 'http://USERNAME:PASSWORD@HOST';
const dispatcher = new ProxyAgent(PROXY_URL);
const response = await request('https://google.com', {
dispatcher
});
// HTTP 407 Proxy Authentication Required
console.log('response', response);
Expected Behavior
Server response result
Logs & Screenshots
/home/negezor/projects/repro/node_modules/undici/lib/proxy-agent.js:67
callback(new RequestAbortedError('Proxy response !== 200 when HTTP Tunneling'))
^
RequestAbortedError [AbortError]: Proxy response !== 200 when HTTP Tunneling
at Client.connect (/home/negezor/projects/repro/node_modules/undici/lib/proxy-agent.js:67:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'UND_ERR_ABORTED'
}
Environment
Node.js v18.10.0
Undici v5.10.0
Additional context
This is easy to fix, however this is non-obvious behavior.
import { ProxyAgent, request } from 'undici';
const PROXY_URL = 'http://USERNAME:PASSWORD@HOST';
const url = new URL(PROXY_URL);
const dispatcher = new ProxyAgent({
uri: PROXY_URL,
auth: Buffer.from(`${url.username}:${url.password}`).toString('base64')
});
const response = await request('https://google.com', {
dispatcher
});
console.log('response', response);
// Full response
Bug Description
I was expecting the classic behavior of passing a proxy URL to be parsed apart. However, ProxyAgent ignores the auth part.
Reproducible By
Expected Behavior
Server response result
Logs & Screenshots
Environment
Node.js v18.10.0
Undici v5.10.0
Additional context
This is easy to fix, however this is non-obvious behavior.