Skip to content

Commit f93d91a

Browse files
committed
Don't resolve if on network
1 parent 2558c3e commit f93d91a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/react-dev-utils/WebpackDevServerUtils.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,25 @@ function resolveLoopback(proxy) {
193193
if (o.hostname !== 'localhost') {
194194
return proxy;
195195
}
196-
try {
196+
// Unfortunately, many languages (unlike node) do not yet support IPv6
197+
// this means even though localhost resolves to ::1, the application
198+
// must fall back to IPv4 (on 127.0.0.1).
199+
// We can re-enable this in a few years.
200+
/*try {
197201
o.hostname = address.ipv6() ? '::1' : '127.0.0.1';
198202
} catch (_ignored) {
199203
o.hostname = '127.0.0.1';
204+
}*/
205+
206+
try {
207+
// Check if we're on a network; if we are, chances are we can resolve
208+
// localhost. Otherwise, we can just be safe and assume localhost is
209+
// IPv4 for maximum compatibility.
210+
if (!address.ip()) {
211+
o.hostname = '127.0.0.1';
212+
}
213+
} catch (_ignored) {
214+
o.hostname = '127.0.0.1';
200215
}
201216
return url.format(o);
202217
}

0 commit comments

Comments
 (0)