8000 fix: prefer `devServer.public` as the custom url for browser to open … · vuejs/vue-cli@0824407 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0824407

Browse files
Devil-Conghaoqunjiang
authored andcommitted
fix: prefer devServer.public as the custom url for browser to open (#4169)
fixes #3747 (cherry picked from commit 76e7c38)
1 parent 1bc8006 commit 0824407

File tree

1 file changed

+5
-4
lines changed
  • packages/@vue/cli-service/lib/commands

1 file changed

+5
-4
lines changed

packages/@vue/cli-service/lib/commands/serve.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ module.exports = (api, options) => {
9292
port,
9393
isAbsoluteUrl(options.publicPath) ? '/' : options.publicPath
9494
)
95+
const localUrlForBrowser = publicUrl || urls.localUrlForBrowser
9596

9697
const proxySettings = prepareProxy(
9798
projectDevServerOptions.proxy,
@@ -201,7 +202,7 @@ module.exports = (api, options) => {
201202
let copied = ''
202203
if (isFirstCompile && args.copy) {
203204
try {
204-
require('clipboardy').writeSync(urls.localUrlForBrowser)
205+
require('clipboardy').writeSync(localUrlForBrowser)
205206
copied = chalk.dim('(copied to clipboard)')
206207
} catch (_) {
207208
/* catch exception if copy to clipboard isn't supported (e.g. WSL), see issue #3476 */
@@ -250,15 +251,15 @@ module.exports = (api, options) => {
250251
const pageUri = (projectDevServerOptions.openPage && typeof projectDevServerOptions.openPage === 'string')
251252
? projectDevServerOptions.openPage
252253
: ''
253-
openBrowser(urls.localUrlForBrowser + pageUri)
254+
openBrowser(localUrlForBrowser + pageUri)
254255
}
255256

256257
// Send final app URL
257258
if (args.dashboard) {
258259
const ipc = new IpcMessenger()
259260
ipc.send({
260261
vueServe: {
261-
url: urls.localUrlForBrowser
262+
url: localUrlForBrowser
262263
}
263264
})
264265
}
@@ -267,7 +268,7 @@ module.exports = (api, options) => {
267268
// so other commands can do api.service.run('serve').then(...)
268269
resolve({
269270
server,
270-
url: urls.localUrlForBrowser
271+
url: localUrlForBrowser
271272
})
272273
} else if (process.env.VUE_CLI_TEST) {
273274
// signal for test to check HMR

0 commit comments

Comments
 (0)
0