fix: ensure profile middleware respects full path

This commit is contained in:
Matthieu
2025-09-18 08:40:09 +02:00
parent 4787c1ea8f
commit ac948bbf5e

View File

@@ -6,10 +6,16 @@ export default defineNuxtRouteMiddleware(async (to) => {
const rawPath = to?.path ?? ''
const normalizedPath = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
const fullPath = to?.fullPath ?? normalizedPath
const routeName = typeof to?.name === 'string' ? to.name : ''
const isProfilesRoute = normalizedPath.startsWith('/profiles') || routeName.startsWith('profiles')
const isProfilesRoute =
normalizedPath.startsWith('/profiles') ||
fullPath.startsWith('/profiles') ||
routeName.startsWith('profiles')
if (!activeProfile.value && !isProfilesRoute) {
return navigateTo('/profiles')
if (!normalizedPath.startsWith('/profiles')) {
return navigateTo('/profiles')
}
}
})