router.beforeEach((to, from, next) => { if (sessionStorage.getItem('authToken') !== null || to.path === '/auth') { next() } else { next('/auth') } } <----------- })