diff --git a/src/router/index.js b/src/router/index.js index 009024bec..b45b79581 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -69,11 +69,6 @@ export const constantRoutes = [ component: () => import('@/views/404'), hidden: true }, - { - path: '*', - redirect: '/404', - hidden: true - }, ...commonRoutes ] diff --git a/src/utils/startup.js b/src/utils/startup.js index 6b8bd699e..fe3b399df 100644 --- a/src/utils/startup.js +++ b/src/utils/startup.js @@ -81,10 +81,16 @@ export async function generatePageRoutes({ to, from, next }) { try { // try get user profile // generate accessible routes map based on roles - const accessRoutes = await store.dispatch('permission/generateRoutes', { to, from }) + let accessRoutes = await store.dispatch('permission/generateRoutes', { to, from }) + // Incorrect route, jump to 404 + accessRoutes = [...accessRoutes, { + path: '*', + redirect: '/404', + hidden: true + }] // dynamically add accessible routes - Vue.$log.debug('All routes: ', accessRoutes) + Vue.$log.debug('All routes:', accessRoutes) router.addRoutes(accessRoutes) await store.dispatch('permission/generateViewRoutes', { to, from })