Repository: create-react-app
Issue: CRA assumes offline mode eventhough a local registry is available
Labels: needs triage,issue: bug report

<!--
    Please note that your issue will be fixed much faster if you spend about
    half an hour preparing it, including the exact reproduction steps and a demo.

    If you're in a hurry or don't feel confident, it's fine to report bugs with
    less details, but this makes it less likely they'll get fixed soon.

    In either case, please use this template and fill in as many fields below as you can.

    Note that we don't provide help for webpack questions after ejecting.
    You can find webpack docs at https://webpack.js.org/.
-->

### Describe the bug

In a setup with no direct internet connection and no proxy, but a reachable local registry, CRA assumes to be offline eventhough dependencies can be fetched from that registry. This makes it impossible to use for example the typescript template.
In that setup NPM and Yarn both work without having to use an offline-switch, CRA however forces that switch.

### Did you try recovering your dependencies?

This does not apply. The problem occurs while creating the project.

### Which terms did you search for in User Guide?

"offline", "registry". 
I also searched the issue database for these terms.

### Environment

Windows 10, node 10.16.0,  yarn 1.22.10, npm 6.9.0, CRA 4.0.3, 
local nexus registry
no direct internet connection
no NATed Internet connection
no proxy
no public DNS


$ npx create-react-app delme --template typescript

Creating a new React app in ...\delme.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template-typescript...

**You appear to be offline.**
Falling back to the local Yarn cache.

yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find any versions for "react" that matches "latest" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact --offline react react-dom react-scripts cra-template-typescript --cwd C:\SPU\web\projekte\sonstige\delme has failed.

Deleting generated file... package.json
Deleting delme/ from ...
Done.



### Steps to reproduce

1. clean npm cache, 
2. clean yarn cache, 
3. use a DNS Server that only resolves local addresses
4. use a local registry
5. start npx install something --template typescript


### Expected behavior

Since the registry is available packages can be fetched from there. The (in this case) missing template should be fetched from there

### Actual behavior

"You appear do be offline" is reported and the installation aborts (see above)

### Reproducible demo

Not possible as this issue will only happen in a very specifig environment.


### Some more info

I tracked the issue down to the function checkIfOnline() in createReactApp.js which tries to reach a hardcoded yarn registry (registry.yarnpkg.com). The issue will disappear if the check is done by resolving the actually used registry, as reported by yarnpkg config get registry.

I could supply a PR to fix this, but I can't say if there is any need to actually resolve the central yarnpkg's repository. In my tests everything worked by replacing the registry host (by actually patching createReactApp.js) with my local registry.

I admit this is a very special setup, but still IMHO it would make more sense to check the reachability of the actually used registry, than the central one.

This issue might be a dupe of this really old issue here: https://github.com/facebook/create-react-app/issues/5680