Description
Is your proposal related to a problem?
(Related issue: #11302)
Node.js >=18.16, localhost will be resolved to ipv6 address [::1] by default, instead of 127.0.0.1. Some popular dev servers like Angular follow this feature. But React still resolves its default hostname "localhost" to ipv4.
See line 56 in "create-react-app\packages\react-scripts\scripts\start.js":
const HOST = process.env.HOST || '0.0.0.0';
This is sometimes a little unfriendly while users use some node.js based functions resolving localhost in a different way.
For example:
proxyApp.web(
req,
res,
{
target, // target is the url started by React, e.g. http://localhost:3000
secure: false,
toProxy: true,
},
onConnectionLost(req, res, target)
);
In this case, the valid target is actually http://127.0.0.1:3000, while node base functions like proxyApp.web() resolve its host name to [::1]. This problem affects users who use Node.js >=18.16
So is it possible to change the default host to follow node 18?
Describe the solution you'd like
For example, should line 56 in "create-react-app\packages\react-scripts\scripts\start.js" be changed to something like:
const HOST = process.env.HOST || localhost;
or
const HOST = process.env.HOST || "::";