Skip to content

Commit

Permalink
feat: use host url to open browser (#19414)
Browse files Browse the repository at this point in the history
Co-authored-by: liyan1 <[email protected]>
Co-authored-by: sapphi-red <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2025
1 parent 4bcd79a commit f6926ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,15 @@ export async function _createServer(
},
openBrowser() {
const options = server.config.server
const url =
server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
const host = options.host
let url: string | undefined
if (typeof host === 'string') {
url = [
...(server.resolvedUrls?.local ?? []),
...(server.resolvedUrls?.network ?? []),
].find((url) => url.includes(host))
}
url ??= server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
if (url) {
const path =
typeof options.open === 'string'
Expand Down

0 comments on commit f6926ca

Please sign in to comment.