import { useProfileSession } from '#imports' 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') if (!activeProfile.value && !isProfilesRoute) { return navigateTo('/profiles') } })