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
If the environment variable `https_proxy` is set, test that the proxy name is resolveable rather than 'registry.yarnpkg.com'.
This fixes #2832.
  • Loading branch information
bsyk committed Aug 2, 2017
1 parent b1c1224 commit 235739e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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 @@ -613,7 +614,13 @@ function checkIfOnline(useYarn) {
}

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

0 comments on commit 235739e

Please sign in to comment.