Skip to content

Commit 6d35461

Browse files
jkzinghaoqunjiang
authored andcommitted
fix(cli-service): do not display absolute baseUrl (#2900)
1 parent e4e151b commit 6d35461

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = (api, options) => {
4242
const prepareProxy = require('../util/prepareProxy')
4343
const launchEditorMiddleware = require('launch-editor-middleware')
4444
const validateWebpackConfig = require('../util/validateWebpackConfig')
45+
const isAbsoluteUrl = require('../util/isAbsoluteUrl')
4546

4647
// resolve webpack config
4748
const webpackConfig = api.resolveWebpackConfig()
@@ -89,7 +90,7 @@ module.exports = (api, options) => {
8990
protocol,
9091
host,
9192
port,
92-
options.baseUrl
93+
isAbsoluteUrl(options.baseUrl) ? '/' : options.baseUrl
9394
)
9495

9596
const proxySettings = prepareProxy(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function isAbsoluteUrl (url) {
2+
// A URL is considered absolute if it begins with "<scheme>://" or "//"
3+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url)
4+
}

0 commit comments

Comments
 (0)