export default defineNuxtRouteMiddleware(async (to, from) => { if (import.meta.server) return const { data } = await useFetch('/api/auth/verify') if (!data.value?.authenticated) { // Preserve the original URL so user can be redirected back after login return navigateTo(`/login?redirect=${encodeURIComponent(to.fullPath)}`) } })