Medium / phantomjs

NPM wrapper for installing phantomjs
Other
1.42k stars 436 forks source link

Proxy prefers https variant, regardless of phantomjs_cdnurl scheme or no_proxy setting. #797

Open inflammable opened 6 years ago

inflammable commented 6 years ago

We've hit a strange problem where phantomjs-prebuilt will attempt to use a proxy for a server that doesn't require proxy access, and will use the wrong proxy for the http scheme specified in phantomjs CDN URL. In part this seems to be because of the way node/npm prioritises environment variables over the .npmrc in the project.

In the scenario that:

Assuming the code at https://github.com/Medium/phantomjs/blob/master/install.js#L154 is where this is setup - that behaviour makes sense.

Ideally the use of a proxy would be based on:

And the type of proxy would be based on:

As a slightly obfuscated example of it failing today:

$ export npm_config_https_proxy="https://https.proxy.internal:8080/"
$ export npm_config_no_proxy="localcdn.internal"
$ npm install phantomjs-prebuilt --phantomjs_cdnurl=http://localcdn.internal/npm

> phantomjs-prebuilt@2.1.16 install /.../node_modules/phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Downloading http://localcdn.internal/npm/phantomjs-2.1.1-macosx.zip
Saving to /.../phantomjs/phantomjs-2.1.1-macosx.zip
Using proxy https://https.proxy.internal:8080/
Using npmconf ca
Receiving...
^C