Skip to content

Commit 235739e

Browse files
committed
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 facebook#2832.
1 parent b1c1224 commit 235739e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: packages/create-react-app/createReactApp.js

+8-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');
@@ -613,7 +614,13 @@ function checkIfOnline(useYarn) {
613614
}
614615

615616
return new Promise(resolve => {
616-
dns.lookup('registry.yarnpkg.com', err => {
617+
let host = 'registry.yarnpkg.com';
618+
// If a proxy is defined, we likely can't resolve external hostnames.
619+
// Try to resolve the proxy name as an indication of a connection.
620+
if (process.env.https_proxy) {
621+
host = url.parse(process.env.https_proxy).hostname;
622+
}
623+
dns.lookup(host, err => {
617624
resolve(err === null);
618625
});
619626
});

0 commit comments

Comments
 (0)