Skip to content

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

Merged
antfu merged 6 commits intovitejs:mainfrom
patak-cat:fix/hostname-rework
May 12, 2021
Merged

fix(server): hostname defaults to localhost, fix #3355#3383
antfu merged 6 commits intovitejs:mainfrom
patak-cat:fix/hostname-rework

Conversation

@patak-cat
Copy link
Copy Markdown
Member

@patak-cat patak-cat 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

nihalgonsalves
nihalgonsalves previously approved these changes May 12, 2021
Copy link
Copy Markdown
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.

Co-authored-by: Nihal Gonsalves <nihal@nihalgonsalves.com>
patak-cat 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