I created a Vue.js project with following configuration in package.json
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.2",
"core-js": "^3.6.5",
"http-proxy-middleware": "^1.0.5",
"vee-validate": "^3.3.7",
"vue": "^2.6.11",
"vue-router": "^3.4.0",
"vue-sanitize": "^0.2.0",
"vuex": "^3.5.1"
},
I can test the project at the url http://127.0.0.1:8080/test/test after running npm run serve.
However, when I built the project with npm run build and moved the dist folder to Apache Tomcat, I get a 404 error for the url http://127.0.0.1:8080/vue/test/test (vue is the folder where the dist contents are placed).
I checked the browser console and see the following error.
GET http://localhost:8080/vue/test/test [HTTP/1.1 404 5ms]
Here is the router configuration.
export default new Router({
mode : 'history',
base: '/vue/',
routes : [
{
path : '/:param1/:param2',
name : 'comp1',
component : comp1,
props : true
}
]})
Update: I also followed the steps described in this answer to set a base path in the Router, but it still doesnt work. https://stackoverflow.com/a/60635441/6352160
How can I debug this error? Why would the same code fail on npm run build and deploy, but work on npm run serve?