Show localhost in URL for IPv6 addresses #17160
Open
+1
−1
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 does it do?
Treat
::
like0.0.0.0
and::1
like127.0.0.1
when showing the local Strapi URL.Why is it needed?
By default Strapi listens on
0.0.0.0
i.e. only on IPv4. This is a problem because Node v18 (current LTS) defaults to IPv6. So if you're running another Node process, say a Next.js app, that tries to connect to Strapi it will probably fail withECONNREFUSED ::1:1337
. (Probably because it depends on how exactly the network is configured on your machine.)That's why I set
HOST=::
in.env
.::
the IPv6 equivalent of0.0.0.0
.But that way Strapi shows an invalid URL in the logs, which won't work if somebody tries to open it in the browser. Either
strapi develop
orstrapi start
print:This change should make it show
http://localhost:1337
, like it already does for0.0.0.0
.How to test it?
Start a Strapi app and see what URL it prints to the console.
Related issue(s)/PR(s)
#12285