Skip to content

Commit

Permalink
Adjust the checkIfOnline check if in a corporate proxy environment …
Browse files Browse the repository at this point in the history
…(#2884)

* Adjust the `checkIfOnline` check if in a corporate proxy environment
If the environment variable `https_proxy` is set, test that the proxy name is resolveable rather than 'registry.yarnpkg.com'.
This fixes #2832.

* Adjust to check yarnpkg.com first, then check the proxy address only if that failed
  • Loading branch information
bsyk authored and swengorschewski committed Oct 12, 2017
1 parent 8b361cd commit 7191714
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const semver = require('semver');
const dns = require('dns');
const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
const url = require('url');
const hyperquest = require('hyperquest');

const packageJson = require('./package.json');
Expand Down Expand Up @@ -614,7 +615,15 @@ function checkIfOnline(useYarn) {

return new Promise(resolve => {
dns.lookup('registry.yarnpkg.com', err => {
resolve(err === null);
if (err != null && process.env.https_proxy) {
// If a proxy is defined, we likely can't resolve external hostnames.
// Try to resolve the proxy name as an indication of a connection.
dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
resolve(proxyErr == null);
});
} else {
resolve(err == null);
}
});
});
}

0 comments on commit 7191714

Please sign in to comment.