Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDN Address not working in baseUrl #2380

Open
AzaZPPL opened this issue Aug 28, 2018 · 5 comments
Open

CDN Address not working in baseUrl #2380

AzaZPPL opened this issue Aug 28, 2018 · 5 comments
Labels
needs team repro We acknowledged your report and will soon try to reproduce it scope: cli-service build

Comments

@AzaZPPL
Copy link

AzaZPPL commented Aug 28, 2018

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.

@Akryum Akryum added scope: cli-service build needs team repro We acknowledged your report and will soon try to reproduce it labels Sep 2, 2018
@zhougonglai
Copy link

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

@aprilandjan
Copy link

aprilandjan commented Sep 12, 2018

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.

@rushairer
Copy link

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

set the 'base' to '/'

@AzaZPPL @aprilandjan

@aprilandjan
Copy link

@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

@rushairer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs team repro We acknowledged your report and will soon try to reproduce it scope: cli-service build
Projects
None yet
Development

No branches or pull requests

5 participants