Skip to content
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

feat: print resolved address for localhost #8647

Merged

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Jun 18, 2022

BREAKING CHANGE: server.printUrls / previewServer.printUrls are now async.

Description

#8543 used verbatim: true to make localhost resolved by DNS.
But it was removed by #8642 for compatibility reasons with node ecosystem.

This PR changes the hostname printed when server starts.
The resolved address is used when the node.js resolver differs from DNS.
The printed url differs from the config so it looks a bit weird.
But this can be avoided by calling dns.setDefaultResultOrder('verbatim') in vite.config.js.

This will fix the hijacking issue which #8543 tried to solve.

Why does this solve them?

before
Vite: 127.0.0.1:3000
Other server: [::]:3000
Log output: localhost:3000 => [::1]:3000 Mismatch

#8543
Vite: localhost:3000 => [::1]:3000
Other server: [::]:3000
Log output: localhost:3000 => [::1]:3000

This PR
Vite: localhost:3000 => [::1]:3000
Other server: [::]:3000
Log output: [::1]:3000 (if DNS resolves to [::1], localhost:3000 will be printed)

Additional context

I'll update the docs in #8634 (or update in this PR if #8634 is merged earlier).


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added p2-nice-to-have Not breaking anything but nice to have (priority) breaking change labels Jun 18, 2022
@sapphi-red sapphi-red marked this pull request as ready for review June 18, 2022 03:20
@sapphi-red
Copy link
Member Author

sapphi-red commented Jun 18, 2022

TODO: update migration.md done

@sapphi-red sapphi-red mentioned this pull request Jun 18, 2022
11 tasks
docs/guide/migration.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants