-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite's localhost
is now incompatible with node's
#7075
Comments
Also discussed at #5241 (comment) Using
I think the change is acceptable. |
What about a two-step change? We could not override With the override in place, the only alternative is to explicitly specify either |
Describe the bug
As of v17, node respects the order of IP addresses returned by the system resolver.
This means
localhost
might resolve to127.0.0.1
in a system and::1
in another. As vite defaults to127.0.0.1
and even translateslocalhost
to it since #2977, it means starting up a vite server without a configured host (or with--host localhost
) and doingnet.connect(port)
ornet.connect(port, 'localhost')
can fail.I believe this could be fixed by defaulting to
'localhost'
instead of the ipv4 here, but I'm unsure if that has negative complications:vite/packages/vite/src/node/utils.ts
Lines 587 to 594 in 33f9671
Why was
localhost
considered insecure? A system might even have reasons to have it resolved to a different, local interface—however unconventional that might be.If there are no objections, I can open a PR with that change.
Reproduction
I'm not sure how to create a reproduction; I'd have to patch node's dns resolution.
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: