https requests failing when using a proxy
See original GitHub issueIssue Description
I’m using the dynamics-web-api to make https requests via the squid proxy. The https request works fine when doing a curl command. But I get the following error “The requested URL could not be retrieved”.
When the curl command is run in squid I can see:
225 172.17.0.1 TCP_TUNNEL/200 5122 CONNECT example.com:443 - HIER_DIRECT/40.110.1111.111 -
Whereas when using the dynamics API I get
0 172.17.0.1 TAG_NONE/501 5910 GET example.com - HIER_NONE/- text/html
I presume it’s down to this https://github.com/AleksandrRogov/DynamicsWebApi/blob/v1.7.1/lib/requests/http.js#L51. But just wanted to confirm. It probably needs to make a CONNECT request first then perform the request. https://stackoverflow.com/questions/34078995/how-can-i-use-an-https-proxy-with-node-js-https-request-client
Would the ideal solution be to use something like axios to perform the requests?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
@nabeelamir-defra I am not going to use axios, because those packages do not require it and I don’t want to introduce another dependecy (I’ve already added 2). Hope it will work for you fine. The patch will be ready soon.
Sorry for getting back to you so late. Did you use the https-proxy-agent with the existing solution or with axios?
Using axios seem to be more robust and require less code. The axios code looks ok (I haven’t tested it), but you don’t need to configure the proxy.
axios respects the http_proxy, https_proxy and no_proxy environment variables already. From the docs:
And the code https://github.com/axios/axios/blob/master/lib/adapters/http.js#L125