Created by: Manc
This PR fixes issues #12304 and #11762 – “react-scripts start
fails when both HOST
and proxy
are defined”.
Steps to verify the issue
- Add a
proxy
inpackage.json
of a new project (if verifying within the monorepo code, usepackages/react-scripts/package.json
). - Set a
HOST
environment variable and run thestart
script, e.g:HOST=example.local yarn run start
- The script will fail with error message:
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. options.allowedHosts[0] should be a non-empty string.
After applying this patch, the script will run as expected, setting the allowedHost
property of the Webpack config to the given hostname.
Explanation
The function createDevServerConfig
expects the hostname as string for its second argument, but instead of HOST
, urls.lanUrlForConfig
is provided and its value is undefined
.
It appears, this bug has been in introduced all the way back in 2017.