Vue-cli: CDN Address not working in baseUrl

Created on 28 Aug 2018  路  5Comments  路  Source: vuejs/vue-cli

Version

3.0.1

Reproduction link

https://github.com/yangmingshan/vue-cli-issue

Node and OS info

Node: 10.9.0 / npm 6.4.0 / MacOS 10.13.6

Steps to reproduce

  1. Set baseUrl in vue.config.js to a CDN url.
  2. Run npm run serve
  3. URL is now set to: http://localhost:8080/https://my.cdn.com/

What is expected?

URL should be set to https://my.cdn.com/

What is actually happening?

Url is set to http://localhost:8080/https://my.cdn.com/


This issue #1545 was fixed with commit 1195aee. In the later commit 1e7fa2c the fix got removed.

needs team repro cli-service build

Most helpful comment

new Router({
mode: process.env.BASE_URL ? 'history' : 'hash',
base: '/',
routes: routes
})

set the 'base' to '/'

@AzaZPPL @aprilandjan

All 5 comments

i think it fix on the vue/cli-service 3.0.1

This is not fixed for now. And the commit 1195aee I think it is not the solution. The document here https://cli.vuejs.org/config/#baseurl about baseurl cannot help eather.

I tried to hack into /node_modules/@vue/cli-service/ in my local machine, change the options.baseUrl into my CDN address (which is used by webpack as output.publicPath, also assetsPublicPath config in previous vue-cli template) at https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/base.js#L37, and then comment the line which throw error at https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/util/validateWebpackConfig.js#L32. Then I build my project, upload to remote host and it finally worked.

Do we really do not need assetsPublicPath anymore in Vue-Cli v3 ? I doubted.

new Router({
mode: process.env.BASE_URL ? 'history' : 'hash',
base: '/',
routes: routes
})

set the 'base' to '/'

@AzaZPPL @aprilandjan

@rushairer Thanks bro you remind me that the vue-router base could be configured manually, I almost forgot that - -. So I only need to define my own enviroment variable as router base in webpack config, and this could be solved easily. I just made it tooo complicated, lol.

Maybe the template project with router could be improved to prevent such problems, or the documention could cover this situation. Still I think it is necessary to discriminate assetsPublicPath to baseUrl

@aprilandjan
You are welcome. I met the same problem with you yesterday, and then I saw the 'base:/' unconsciously. 馃槀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanderswang picture sanderswang  路  3Comments

brandon93s picture brandon93s  路  3Comments

chasegiunta picture chasegiunta  路  3Comments

BusyHe picture BusyHe  路  3Comments

jgribonvald picture jgribonvald  路  3Comments