I recently added a second router to my Vue.js project, specifically for a dashboard on my website. However, I encountered an issue where if I manually tried to access a specific route like "/admin/contact" or refreshed the page, I would receive a 404 error and the content wouldn't load.
import Vue from 'vue'
import Router from 'vue-router'
import Index from "@/views/Admin/Index.vue";
import ContactIndex from "@/views/Admin/Contact/Index.vue";
Vue.use(Router)
const router = new Router({
mode: "history",
routes: [{
path: '/admin',
name: 'admin',
component: Index,
meta: {
requireAuth: true
}
},
{
path: '/admin/contact',
name: 'contact',
component: ContactIndex,
meta: {
requireAuth: true
}
}
]
})
export default router;
The strange thing is that when I click on a router-link tag that points to the same address ("/admin/contact"), everything works perfectly fine. How can I resolve this issue?