File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments