Skip to content

Commit 7191714

Browse files
bsykswengorschewski
authored andcommittedOct 12, 2017
Adjust the checkIfOnline check if in a corporate proxy environment (#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
1 parent 8b361cd commit 7191714

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎packages/create-react-app/createReactApp.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const semver = require('semver');
4747
const dns = require('dns');
4848
const tmp = require('tmp');
4949
const unpack = require('tar-pack').unpack;
50+
const url = require('url');
5051
const hyperquest = require('hyperquest');
5152

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

615616
return new Promise(resolve => {
616617
dns.lookup('registry.yarnpkg.com', err => {
617-
resolve(err === null);
618+
if (err != null && process.env.https_proxy) {
619+
// If a proxy is defined, we likely can't resolve external hostnames.
620+
// Try to resolve the proxy name as an indication of a connection.
621+
dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
622+
resolve(proxyErr == null);
623+
});
624+
} else {
625+
resolve(err == null);
626+
}
618627
});
619628
});
620629
}

0 commit comments

Comments
 (0)