fix(server): hostname defaults to localhost, fix #3355#3382
fix(server): hostname defaults to localhost, fix #3355#3382patak-cat wants to merge 2 commits intovitejs:mainfrom patak-cat:fix/hostname
Conversation
packages/vite/src/node/utils.ts
Outdated
| return Array.from(new Set(arr)) | ||
| } | ||
|
|
||
| export function defaultHostname(host: string | undefined) { |
There was a problem hiding this comment.
suggestion (dx, readability): Isn't it more like a normalize or fallback?
There was a problem hiding this comment.
It is hard to name, it isnt a normalization or fallback either. More like useLocalhostIfPossible
There was a problem hiding this comment.
Ah I see, I trapped and thought it would be the other way around
useLocalhostIfPossible is ugly, but definitely more expressive about what happens 🤔
There was a problem hiding this comment.
Ya, in #3383 this function is gone so we can discuss how to name other things there :)
Co-authored-by: Nihal Gonsalves <nihal@nihalgonsalves.com>
| ? 'Local: ' | ||
| : 'Network: ' | ||
| const host = detail.address | ||
| const host = detail.address.replace('127.0.0.1', 'localhost') |
There was a problem hiding this comment.
Do we want to use defaultHostname here too?
There was a problem hiding this comment.
This is going to be always 'localhost' when calling it.
|
hmm, would this still allow to explicitly pass |
I'll close this PR if we merge this alternative #3383 About |
Description
Fix #3355
After #2977, we lost the hostname defaulting to localhost for
'127.0.0.1'and'0.0.0.0'vite/packages/vite/src/node/server/index.ts
Line 536 in c374a54
This PR adds that logic back, also including
host === undefinedand'::'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?
Before submitting the PR, please make sure you do the following
fixes #123).