From 4787c1ea8f02092cf7861596f62eae37fdd2c132 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 18 Sep 2025 08:35:18 +0200 Subject: [PATCH] fix: normalize route path in profile middleware --- app/middleware/profile.global.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/middleware/profile.global.ts b/app/middleware/profile.global.ts index bd589b4..d077317 100644 --- a/app/middleware/profile.global.ts +++ b/app/middleware/profile.global.ts @@ -4,9 +4,10 @@ export default defineNuxtRouteMiddleware(async (to) => { const { ensureSession, activeProfile } = useProfileSession() await ensureSession() - const path = to.path || '' - const routeName = typeof to.name === 'string' ? to.name : '' - const isProfilesRoute = path.startsWith('/profiles') || routeName.startsWith('profiles') + const rawPath = to?.path ?? '' + const normalizedPath = rawPath.startsWith('/') ? rawPath : `/${rawPath}` + const routeName = typeof to?.name === 'string' ? to.name : '' + const isProfilesRoute = normalizedPath.startsWith('/profiles') || routeName.startsWith('profiles') if (!activeProfile.value && !isProfilesRoute) { return navigateTo('/profiles')