question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect configuration of 'base' in vue-cli-plugin-router

See original GitHub issue

Version

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:open
  • Created 4 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
sodateacommented, Jul 19, 2019

There are 3 places that referenced BASE_URL:

  1. <link rel="icon" href="<%%= BASE_URL %%>favicon.ico"> in index.html. Here it means publicPath
  2. ${process.env.BASE_URL}service-worker.js in PWA plugin. Here BASE_URL should be a relative path to the website root, we need to prompt a warning if it is not a directory path.
  3. base: process.env.BASE_URL in router config. Here it means the website root (where the index.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 (thus publicPath becomes a full URL starting with a domain name), only the first use case makes sense.

0reactions
posvacommented, Jul 30, 2019

@sodatea Ah I see. As long as the problem does not appear when a correct base is provided, then it’s okay

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found