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

fix(server): hostname defaults to localhost, fix #3355 #3383

Merged
merged 6 commits into from
May 12, 2021
Merged

fix(server): hostname defaults to localhost, fix #3355 #3383

merged 6 commits into from
May 12, 2021

Conversation

patak-dev
Copy link
Member

@patak-dev patak-dev commented May 12, 2021

Description

Rework of #3382, avoiding replacing '127.0.0.1' by 'localhost' if this was defined by the user using host

It also fixes options.host === false.

The hint to use host in the console is not shown if the user sets 127.0.0.1 by hand.


Fix #3355

After #2977, we lost the hostname defaulting to localhost for '127.0.0.1' and '0.0.0.0'

if (hostname === '0.0.0.0') hostname = 'localhost'

This PR adds that logic back, also including host === undefined and '::' that should be treated equally to '0.0.0.0'

The reported URL in the console also replaces '127.0.0.1' by localhost now.


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.

--

Replaces + closes #3382

packages/vite/src/node/preview.ts Outdated Show resolved Hide resolved
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
nihalgonsalves
nihalgonsalves previously approved these changes May 12, 2021
Copy link
Member

@nihalgonsalves nihalgonsalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this structure 👍🏼 It's more understandable now, and there aren't replacements in different places.

packages/vite/src/node/preview.ts Outdated Show resolved Hide resolved
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
packages/vite/src/node/logger.ts Show resolved Hide resolved
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
Co-authored-by: Nihal Gonsalves <nihal@nihalgonsalves.com>
patak-dev and others added 2 commits May 12, 2021 14:53
Co-authored-by: Nihal Gonsalves <nihal@nihalgonsalves.com>
@antfu antfu merged commit 8b5a6a8 into vitejs:main May 12, 2021
fi3ework pushed a commit to fi3ework/vite that referenced this pull request May 22, 2021
…3383)

Co-authored-by: Nihal Gonsalves <nihal@nihalgonsalves.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If I set server.host as true and server.open it doesn't work
4 participants