Я запутался, почему это не работает.
Маршруты
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '/', component: Home, name: 'Home', meta: { requiresAuth: true }},
{ path: '/adminarea', component: Admin, name:"Admin", meta: { requiresAuth: true }},
{ path: '/login', component: Login, name: 'Login'},
{ path: '/signup', component: Register, name: 'Signup'},
]
});
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
// this route requires auth, check if logged in
// if not, redirect to login page.
if (!store.getters.getAuth) {
next({ name: 'Login' })
} else {
next();
}
} else {
next()
}
});
to.matched. некоторые (record => record.meta.requiresAuth эта строка должна разрешать только маршруты с мета requireAuth, но я не знаю, почему это разрешает и другие маршруты.
Я могу вручную получить доступ к входу и регистрации страниц. Я не могу понять, что здесь не так.