node-pre-gyp: Unable to use proxy authentication
Current Behavior
I set auth-proxy address to npm proxy as following and I got invalid proxy error when I built some library.
- npm proxy setting
https-proxy=http://id:pass@example.com:18080/
proxy=http://id:pass@example.com:18080/
- error
node-pre-gyp WARN download ignoring invalid "proxy" config setting: "http://id:pass@example.com:18080/"
Expected Behavior
The build process uses proxy config setting.
Additional Info
In the following code(L63), it looks like auth-proxy and 5 digits port is not taken into account. I checked whether node-https-proxy-agent(L65) supports auth-proxy, and I guess it supports auth-proxy from this comment. https://github.com/mapbox/node-pre-gyp/blob/f9b39484f17955d83cdab42c178a600467fe96bd/lib/install.js#L63-L75
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (3 by maintainers)
Thanks for the great work guys! I really appreciate that. Just wanted to report back that our CI is happy again as well: It’s correctly downloading a pre-built bcrypt binary via our corporate proxy. 👍
i just pushed a version making your changes - i think it makes perfect sense to let
node-fetchhandle the parsing.url.parseis deprecated and parsing the url should be the responsibility of the api in most cases. i just tested locally and all seems to work, so i pushed the changes to the branch. if you want to try again, feel free to, but as they are your changes i think everything will work just fine.Maybe related: The switch from
needletonode-fetchseems to have broken proxy support for us as well (without proxy authentication). After upgradingbcryptfrom5.0.0to5.0.1our builds are now failing because Python is needed to build from source:In my experience, only the now deprecated
requestlibrary ever got proxy support right. Every other HTTP library I tried either didn’t support proxies at all or failed for edge-cases (e.g. redirects not going through the proxies). 😞@bmacnaughton - It works!
I agree with you, because
node-fetchconstructor parses a request url at first, so we don’t need to parse the url in most cases.Thank you for your rapidly and great supports!
@bmacnaughton - Sorry for the late reply. I got an following error.
I found out the part(L70) that seems to be the cause. https://github.com/mapbox/node-pre-gyp/blob/a0100abca39b53184a28fd7c93789e66eb136c1d/lib/install.js#L67-L72
I changed to following and it works for me, but I don’t understand for detail yet, because I haven’t checked
node-fetchargs at well. https://github.com/feuxfollets1013/node-pre-gyp/blob/13ea032e189b3efa224923e6623805694ad76a4f/lib/install.js#L67-L70Sorry for the late reply! This looks good to me:
Thanks for the work, @bmacnaughton!
I made a few changes to your code and tried to run it. In my environment,
Non-SSL URL w/ httpsAgentstatus is200.I was able to download it successfully too.
Results
@soulchild - i will take a look at this sometime this week. thanks for your detailed thoughts.
there was some risk to replacing
request(now unsupported and deprecated) with the modernnode-fetch, but continuing to use an unsupported and deprecated package wasn’t an alternative.