Posts

Showing posts with the label vue-router

vue js:routes not found when page reloads

vue js:routes not found when page reloads Here is simple vue-routing const Foo = { template: ' foo ' } const Bar = { template: ' bar ' } const routes = [ { path: '/foo', component: Foo }, { path: '/bar', component: Bar } ]; const router = new VueRouter({ routes:routes, mode: 'history' }); var app = new Vue({ router, data: { message: 'Hello Vue!' }, mounted:function(){ } }).$mount('#app'); In HTML <router-link to="/foo">Go to Foo</router-link> <router-link to="/bar">Go to Bar</router-link> <router-view></router-view> The links loaded properly (ie : /foo and /bar ) when i click on it but if i refresh any vue routed url (ie /foo or /bar ) url i will get error message /foo /bar /foo /bar cannot get the page I am serving it with simple express server app.get('/', (req, res) => res.sendFile('index.html',{ r...