mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-15 20:48:03 +00:00
Debug sessions
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import Vue from 'vue'
|
||||
import Axios from 'axios'
|
||||
import VueRouter from 'vue-router'
|
||||
import Home from '../views/Home.vue'
|
||||
|
||||
const instance = Axios.create({
|
||||
baseURL: 'https://localhost:3000',
|
||||
withCredentials: true
|
||||
})
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const routes = [
|
||||
@@ -34,4 +40,23 @@ const router = new VueRouter({
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.name === 'Home') {
|
||||
instance.get('/auth')
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
next()
|
||||
} else {
|
||||
next('/login')
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error.response)
|
||||
next('/login')
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user