From b568b224611f821b383e8568517d67e5669bdafd Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 18 Sep 2025 10:12:41 +0200 Subject: [PATCH] fix: keep session middleware from redirecting prematurely --- app/middleware/profile.global.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/middleware/profile.global.ts b/app/middleware/profile.global.ts index 97f8b53..2019a49 100644 --- a/app/middleware/profile.global.ts +++ b/app/middleware/profile.global.ts @@ -1,7 +1,7 @@ import { useProfileSession } from '#imports' export default defineNuxtRouteMiddleware(async (to) => { - const { ensureSession, activeProfile } = useProfileSession() + const { ensureSession, fetchCurrentProfile, activeProfile } = useProfileSession() await ensureSession() const rawPath = to?.path ?? '' @@ -13,6 +13,10 @@ export default defineNuxtRouteMiddleware(async (to) => { fullPath.startsWith('/profiles') || routeName.startsWith('profiles') + if (process.client && !activeProfile.value) { + await fetchCurrentProfile() + } + if (process.client && !activeProfile.value && !isProfilesRoute) { return navigateTo('/profiles') }