1import Vue from 'vue'; 2import VueRouter from 'vue-router'; 3 4//Do not change store or routes import. 5//Exact match alias set to support 6//dotenv customizations. 7import store from '../store'; 8import routes from './routes'; 9 10Vue.use(VueRouter); 11 12const router = new VueRouter({ 13 base: process.env.BASE_URL, 14 routes, 15 linkExactActiveClass: 'nav-link--current', 16}); 17 18router.beforeEach((to, from, next) => { 19 if (to.matched.some((record) => record.meta.requiresAuth)) { 20 if (store.getters['authentication/isLoggedIn']) { 21 next(); 22 return; 23 } 24 next('/login'); 25 } else { 26 next(); 27 } 28}); 29 30export default router; 31