definePageMeta({ middleware: 'auth',})
middleware/auth.ts
import { Routes } from '~/enums/Routes'import QueryEnum from '~/enums/QueryEnum'import getLocalizedRoute from '~/utils/getLocalizedRoute'export default defineNuxtRouteMiddleware(async (_to, from) => { const loggedIn = await useCurrentUser().isLoggedIn() if (!loggedIn) { return navigateTo( getLocalizedRoute( Routes.Login, {}, { [QueryEnum.Redirect]: from.fullPath, } ) ) }})