Got: Proxy support

Created on 17 Sep 2014  Â·  13Comments  Â·  Source: sindresorhus/got

If we use this behind a corporate proxy will fail with ECONNREFUSED and I'm not sure how this can be updated to take a proxy option when it's called.

enhancement ✭ help wanted ✭

All 13 comments

I don't really care about proxy support, but I would consider a good PR ;)

Maybe by using https://github.com/koichik/node-tunnel

@radum is node-tunnel solving your issue? It seems like right solution to your problem for me.

@floatdrop Maybe we should just mention it in the docs?

@sindresorhus there is another module - tunnel-agent, which is used in request. I think it worth to mention them in readme :+1:

@floatdrop tunnel-agent looks like is just node-tunnel: https://github.com/mikeal/tunnel-agent/issues/2

@sindresorhus yeah, but with some patches. Hope they will be ported to node-tunnel soon.

@floatdrop both node-tunnel and tunnel-agent work just fine, but my problem is not with got missing proxy support is with all the other modules using got and not implementing proxy support.

I've already had this conversation some time ago with @sindresorhus (https://github.com/kevva/download/pull/13) and as he pointed out making every module downstream care about it doesn't work in real life because they suck and nobody cares about them but they are here to stay so IMHO I think proxy support should be handled by the low level modules that are actually doing the work.

Now HTTP(S)_PROXY env vars are fairly common and most of us are using them as a standard across all major OS. As an example I think bower had the same issues a long time ago and is using those env vars to make the requests as do many other modules anyways.

@radum thanks for linking this conversation. I agree with @sindresorhus, that it should be implemented in default agent. For example Go has support of HTTP_PROXY (without HTTPS, lol), so Node should do it as well (but apparently it won't https://github.com/joyent/node/issues/1973).

Yeah the entire thing it's broken everywhere I know because I'm behind one and it's a pain everyday.

Python guys have done it also for their request version http://docs.python-requests.org/en/latest/user/advanced/#proxies as for Node, it should be part of core IMHO. Thanks for the alternatives and the doc update anyways.

I'm open to it, but it would need to be in a form of a good PR (preferably with as much code as possible in depending modules) with promise to continue maintaining it, as I'm not interested.

so Node should do it as well (but apparently it won't joyent/node#1973).

That issue is old so someone could try again, but that person should make sure the new issue has a lot of good arguments and evidence of why it should be in core.

as for Node, it should be part of core IMHO

Agreed!

I do wonder why Node can't just use the system proxy settings.

I do wonder why Node can't just use the system proxy settings.

Now it's time to tackle this issue for good! :-)

For socks5 proxies, this package seems to work as a replacement for node-tunnel which only handles http proxies:

const got = require('got');
const SocksProxyAgent = require('socks-proxy-agent');
const proxyOptions = 'socks5://localhost:8080';
const tunnel = new SocksProxyAgent(proxyOptions);


got('https://sindresorhus.com', {
    agent: tunnel
    })
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dominusmars picture dominusmars  Â·  3Comments

AxelTerizaki picture AxelTerizaki  Â·  3Comments

framerate picture framerate  Â·  4Comments

quocnguyen picture quocnguyen  Â·  4Comments

alanzhaonys picture alanzhaonys  Â·  4Comments