-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Can't open browser with 'o' shortcut when using --host option #13575
Labels
p2-nice-to-have
Not breaking anything but nice to have (priority)
Comments
Start a new pull request in StackBlitz Codeflow. |
I think this make sense. Feel free to send a PR! |
bluwy
added
p2-nice-to-have
Not breaking anything but nice to have (priority)
and removed
pending triage
labels
Jun 21, 2023
9 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
When using the Vite 4.4.0 branch/4.4.0-beta.0 release and setting the --host option the shortcut to open the browser with 'o' does not work and returns the following message instead:
No URL available to open in browser
The same message occurs if the "open" option is used to attempt to open a browser automatically on startup.
It appears this issue started to occur after this commit and the issue goes away if reverted: 505f0b9
This issue seems to occur because when a --host is specified we no longer have a "local" address in the "resolvedUrls" used here:
vite/packages/vite/src/node/server/index.ts
Line 438 in 1a0c806
Perhaps simply looking at the "network" addresses for a resolvedUrl if the "local" list is empty is all that is needed:
const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
Reproduction
https://stackblitz.com/edit/vitejs-vite-ccink3?file=package.json&terminal=dev
Steps to reproduce
A minimal example has been included. T
o trigger the issue simply:
--host 192.168.0.100
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: