Incorrect configuration of 'base' in vue-cli-plugin-router
See original GitHub issueVersion
3.4.0
Environment info
System:
OS: macOS 10.14.2
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Binaries:
Node: 10.3.0 - ~/.nvm/versions/node/v10.3.0/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.1.0 - ~/.nvm/versions/node/v10.3.0/bin/npm
Browsers:
Chrome: 75.0.3770.100
Firefox: 65.0
Safari: 12.0.2
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: 3.9.2
@vue/babel-preset-jsx: 1.0.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.0.0
@vue/cli-overlay: 3.9.0
@vue/cli-plugin-babel: ^3.4.0 => 3.9.2
@vue/cli-plugin-eslint: ^3.4.0 => 3.9.2
@vue/cli-service: ^3.4.0 => 3.9.2
@vue/cli-shared-utils: 3.9.0
@vue/component-compiler-utils: 2.6.0
@vue/eslint-config-standard: ^4.0.0 => 4.0.0
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^5.0.0 => 5.2.3
vue: 2.5.2 => 2.5.2
vue-eslint-parser: 5.0.0
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.0
vue-router: 3.0.1 => 3.0.1
vue-style-loader: 4.1.2
vue-template-compiler: 2.5.2 => 2.5.2
vue-template-es2015-compiler: 1.9.1
npmGlobalPackages:
@vue/cli: 3.5.5
Steps to reproduce
1.Create a program with vue-cli3(includes router) 2.In vue.config.js: Set ‘publicPath’ with the domain which different from index.html(like: website on abc.com while publicPath on def.com) 3.Visit the website with invalid words(like ‘@’): abc.com?a=@
What is expected?
Just at abc.com?a=%40
What is actually happening?
Jump to abc.com/def.com?a=%40
we checked the vue-cli-plugin-router,found that in router config there is: ‘base: process.env.BASE_URL’,and in vue-cli-service the ‘process.env.BASE_URL’ was assign to the ‘publicPath’. We remove ‘base: process.env.BASE_URL’,Then everything is ok. So… Is ‘base: process.env.BASE_URL’ a right config?
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Configuration Reference | Vue CLI
The base URL your application bundle will be deployed at (known as baseUrl before Vue CLI 3.3). This is the equivalent of webpack's...
Read more >Vue-router only showing the base route - Stack Overflow
I am trying to work on vue-router. But, I am stuck with a problem and I cannot find the solution after viewing many...
Read more >@vue/cli-plugin-babel | Yarn - Package Manager
Uses Babel 7 + babel-loader + @vue/babel-preset-app by default, but can be configured via babel.config.js to use any other Babel presets or plugins....
Read more >How to Use Vue Router: A Complete Tutorial - Vue School Blog
The first route object has a path / which means this is going to be our base URL. The component property represents what...
Read more >A Beginner's Guide to Vue CLI - SitePoint
The base configuration for a Vue CLI 3 project is webpack and Babel. All the other features can be added via plugins. There...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are 3 places that referenced
BASE_URL
:<link rel="icon" href="<%%= BASE_URL %%>favicon.ico">
inindex.html
. Here it meanspublicPath
${process.env.BASE_URL}service-worker.js
in PWA plugin. HereBASE_URL
should be a relative path to the website root, we need to prompt a warning if it is not a directory path.base: process.env.BASE_URL
in router config. Here it means the website root (where theindex.html
resides).If
publicPath
is a subdirectory path then all the use cases will be fine. But in use cases where static assets are hosted on a CDN (thuspublicPath
becomes a full URL starting with a domain name), only the first use case makes sense.@sodatea Ah I see. As long as the problem does not appear when a correct
base
is provided, then it’s okay