diff --git a/src/router/index.js b/src/router/index.js index f2817f64d..8bad5e397 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,6 +15,7 @@ import { useAcl } from 'src/composables/useAcl'; import { isLoggedIn } from 'src/utils/session'; import { useSession } from 'src/composables/useSession'; +let session = null; const { t, te } = i18n.global; const createHistory = process.env.SERVER @@ -45,7 +46,8 @@ export { Router }; export default defineRouter(function (/* { store, ssrContext } */) { const state = useState(); Router.beforeEach(async (to, from, next) => { - const session = useSession(); + console.error('beforeEach', session); + if (!session) session = useSession(); const outLayout = Router.options.routes[0].children.map((r) => r.name); if (!session.isLoggedIn() && !outLayout.includes(to.name)) { return next({ name: 'Login', query: { redirect: to.fullPath } });