mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Don't resolve localhost if on network (#2332)
* Don't resolve if on network * Update WebpackDevServerUtils.js
This commit is contained in:
@@ -193,10 +193,25 @@ function resolveLoopback(proxy) {
|
||||
if (o.hostname !== 'localhost') {
|
||||
return proxy;
|
||||
}
|
||||
try {
|
||||
// Unfortunately, many languages (unlike node) do not yet support IPv6.
|
||||
// This means even though localhost resolves to ::1, the application
|
||||
// must fall back to IPv4 (on 127.0.0.1).
|
||||
// We can re-enable this in a few years.
|
||||
/*try {
|
||||
o.hostname = address.ipv6() ? '::1' : '127.0.0.1';
|
||||
} catch (_ignored) {
|
||||
o.hostname = '127.0.0.1';
|
||||
}*/
|
||||
|
||||
try {
|
||||
// Check if we're on a network; if we are, chances are we can resolve
|
||||
// localhost. Otherwise, we can just be safe and assume localhost is
|
||||
// IPv4 for maximum compatibility.
|
||||
if (!address.ip()) {
|
||||
o.hostname = '127.0.0.1';
|
||||
}
|
||||
} catch (_ignored) {
|
||||
o.hostname = '127.0.0.1';
|
||||
}
|
||||
return url.format(o);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user