We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4bcd79a commit f6926caCopy full SHA for f6926ca
packages/vite/src/node/server/index.ts
@@ -658,8 +658,15 @@ export async function _createServer(
658
},
659
openBrowser() {
660
const options = server.config.server
661
- const url =
662
- server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
+ const host = options.host
+ let url: string | undefined
663
+ if (typeof host === 'string') {
664
+ url = [
665
+ ...(server.resolvedUrls?.local ?? []),
666
+ ...(server.resolvedUrls?.network ?? []),
667
+ ].find((url) => url.includes(host))
668
+ }
669
+ url ??= server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
670
if (url) {
671
const path =
672
typeof options.open === 'string'
0 commit comments