TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
872 stars 229 forks source link

How create a proxy-agent from proxy URL (no env) #205

Closed cesco69 closed 1 year ago

cesco69 commented 1 year ago

I have just upgraded 'proxy-agent' at latest version.

Prior of latest version I create a proxy in this way

import * as proxy from 'proxy-agent';
proxy('http://172.16.240.254:3128')

Now, with latest version how create a proxy with the proxy url 'http://172.16.240.254:3128'

import { ProxyAgent } from 'proxy-agent';
new ProxyAgent( ??? )
cesco69 commented 1 year ago

After a bit of debug, this seem the correct implementation:

new ProxyAgent({ getProxyForUrl: () => 'http://172.16.120.120:3128' })