Open sherry2h opened 2 years ago
Experiencing the same issue.
I am having the same problem
I had the same issue in context of federated modules and it seems that it's caused by the "BASE_URL" env parameter. Set the "base" parameter from the router to "/" and the problem should be solved.
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
Version
5.0.0-rc.1
Reproduction link
github.com
Environment info
Vue 2
Vue 3
Steps to reproduce
Trying to use Module federation with Vue and
vue-router
, however, if it is withpublicPath
set up, the actual route becomes weird.vue-cli
to create a new Vue app with vue-routerpublicPath
anddevServer
port invue.config.js
npm run serve
For Vue 2 app, the route looks ok on the home page, which ishttp://localhost:9001
When navigating to the about page, the route becomeshttp://localhost:9001/http:/localhost:9001/about
When navigating back to the home page from the about page, the route becomeshttp://localhost:9001/http:/localhost:9001/
For Vue 3 app, the route is already
http://localhost:9001/http://localhost:9001/
on the home page by default. Navigating behaves the same as Vue 2 app, showing duplicatedhttp://localhost:9001/
.What is expected?
No duplication in the actual route
What is actually happening?
showing
http://localhost:9001/http://localhost:9001/
instead ofhttp://localhost:9001/
If the project is set up with Webpack 5 and
vue-router
, the route is all good