Open ...\src\routes\index.ts You will find the below example code. In the below code, we have shown four different routes. MainRoutes is the main layout routing you see after login.
// routes\index.tsimport { createRouter, createWebHistory } from'vue-router';import MainRoutes from'./MainRoutes';import AuthRoutes from'./AuthRoutes';import { useAuthStore } from'@/stores/auth';exportconstrouter=createRouter({ history:createWebHistory(import.meta.env.BASE_URL), routes: [ { path:'/:pathMatch(.*)*',component: () =>import('@/views/pages/maintenance/error/Error404.vue') }, MainRoutes, AuthRoutes ]});router.beforeEach(async (to, from, next) => {// redirect to login page if not logged in and trying to access a restricted pageconstpublicPages= ['/auth/login1'];constauthRequired=!publicPages.includes(to.path);constauth:any=useAuthStore();if (to.matched.some((record) =>record.meta.requiresAuth)) {if (authRequired &&!auth.user) {auth.returnUrl =to.fullPath;returnnext('/auth/login1'); } elsenext(); } else {next(); }});