import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const router = new VueRouter({
// Your router configuration options here
});
router.beforeEach((to, from, next) => {
// Step 1: Check if the route requires authentication
const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
// Step 2: If authentication is required and the user is not authenticated, redirect to the login page
if (requiresAuth && !auth.isAuthenticated()) {
next('/login');
} else {
// Step 3: If the route does not require authentication or the user is authenticated, proceed to the next route
next();
}
});
export default router;