From f93d91a64d9fce5242c814ce7218983637993186 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 22 May 2017 20:43:40 -0400 Subject: [PATCH 1/2] Don't resolve if on network --- .../react-dev-utils/WebpackDevServerUtils.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 70b5e6a7eab..5489815cfea 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -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); } From 4c1b48c1cd867b3ea5d3a62701256c2af7796342 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 22 May 2017 20:47:38 -0400 Subject: [PATCH 2/2] Update WebpackDevServerUtils.js --- packages/react-dev-utils/WebpackDevServerUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 5489815cfea..b681c601f7c 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -193,8 +193,8 @@ function resolveLoopback(proxy) { if (o.hostname !== 'localhost') { return proxy; } - // Unfortunately, many languages (unlike node) do not yet support IPv6 - // this means even though localhost resolves to ::1, the application + // 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 {