Removed targetUrl
replacing localhost
with 127.0.0.1
#52825
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Relands #51887, now that it has gone stale.
This fixes the same issue as #52283, but it does that in a different way. Rather than using the provided hostname, we now use exactly what
server.address()
returns. So if the provided host islocalhost
, it will return[::1]
if IPv6 is used and127.0.0.1
if IPv4 is used, ensuring that the hostname for the proxy server is always correct.http://::1:3000
doesn't seem to be a valid URL (browsers doesn't seem to try to resolve this URL), so this PR also changesNextURL
so that it handles[::1]
, rather than::1
. I've also changed the messageListening on port
in.next/standalone/server.js
so that it displayshttp://[::1]:3000
, rather thanhttp://::1:3000
(this also applies for any other IPv6 hostname).Why?
This seems to be a better solution and works with IPv6 (some OSes seem to resolve
localhost
to[::1]
instead of127.0.0.1
).How?
It does that by doing the aforementioned, and also handles IPv6 hostnames in
next-server.ts
,render-server.ts
,next-swc/.../next-request-helpers.ts
.I've ensured that it works with IPv6 hostnames (such as
::
and::1
), IPv4 hostnames (such as127.0.0.1
) andlocalhost
.