Question: Using package behind HTTP/S Proxy
erikfox opened this issue · comments
Does this package allow you to specify HTTP/S proxy options?
If not, what is the recommended way to route the packages connections through a proxy?
Hmm, no but that's definitely a worthwhile addition! Recently moved to a super vanilla http lib to slim down the payload, make xbrowser easier and shave precious parse/eval initialization ms. https://github.com/brianleroux/tiny-json-http
Can see how this capability could be needed for behind-the-firewall bots. Can you tell me more about the bigger use case driving this?
Hey @brianleroux, a lot of companies (including mine) require all requests from our networks to go through a proxy for security reasons.
Your HTTP lib is hardcoded to reject using any type of agent or overriding the global agent:
opts.agent = false
This makes it impossible for anyone behind a proxy or any enterprise tools to develop with your library (which we'd love to do).
I would love to be able to do something like this:
import slack from 'slack';
import HttpProxyAgent from 'http-proxy-agent';
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
const slack = slack.defaults({
http: {
agent: new HttpProxyAgent(proxy),
}
});
Can do the implementation myself, it seems relatively easy, but because I'd have to go through our Open Source Office, it could take a couple weeks for me to get it to you.
I was thinking about changing your tiny-json-http
to allow opts.agent
to be passed and to not default to false
(which prevents overriding of global agent), and then passing a defaults
object to _exec.js
in this package, where defaults.http
would be passed to http.post()
.
This approach sounds good to me! Def appreciate the help. 💯
Good news! tiny-json-http
has been updated to allow for overriding of http.gobalAgent
https://nodejs.org/api/http.html#http_http_globalagent ---updated here in the latest release