fix: keep session middleware from redirecting prematurely

This commit is contained in:
Matthieu
2025-09-18 10:12:41 +02:00
parent 94f296c64b
commit b568b22461

View File

@@ -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')
}