Skip to content

Commit

Permalink
fix: prefer devServer.public as the custom url for browser to open (#…
Browse files Browse the repository at this point in the history
…4169)

fixes #3747

(cherry picked from commit 76e7c38)
  • Loading branch information
Devil-Cong authored and sodatea committed Jun 24, 2019
1 parent 1bc8006 commit 0824407
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/@vue/cli-service/lib/commands/serve.js
Expand Up @@ -92,6 +92,7 @@ module.exports = (api, options) => {
port,
isAbsoluteUrl(options.publicPath) ? '/' : options.publicPath
)
const localUrlForBrowser = publicUrl || urls.localUrlForBrowser

const proxySettings = prepareProxy(
projectDevServerOptions.proxy,
Expand Down Expand Up @@ -201,7 +202,7 @@ module.exports = (api, options) => {
let copied = ''
if (isFirstCompile && args.copy) {
try {
require('clipboardy').writeSync(urls.localUrlForBrowser)
require('clipboardy').writeSync(localUrlForBrowser)
copied = chalk.dim('(copied to clipboard)')
} catch (_) {
/* catch exception if copy to clipboard isn't supported (e.g. WSL), see issue #3476 */
Expand Down Expand Up @@ -250,15 +251,15 @@ module.exports = (api, options) => {
const pageUri = (projectDevServerOptions.openPage && typeof projectDevServerOptions.openPage === 'string')
? projectDevServerOptions.openPage
: ''
openBrowser(urls.localUrlForBrowser + pageUri)
openBrowser(localUrlForBrowser + pageUri)
}

// Send final app URL
if (args.dashboard) {
const ipc = new IpcMessenger()
ipc.send({
vueServe: {
url: urls.localUrlForBrowser
url: localUrlForBrowser
}
})
}
Expand All @@ -267,7 +268,7 @@ module.exports = (api, options) => {
// so other commands can do api.service.run('serve').then(...)
resolve({
server,
url: urls.localUrlForBrowser
url: localUrlForBrowser
})
} else if (process.env.VUE_CLI_TEST) {
// signal for test to check HMR
Expand Down

0 comments on commit 0824407

Please sign in to comment.