/** Pages for visitors: the landing page and the account forms send players on to their worlds. */ const GUEST_PATHS = ['/', '/login', '/register'] /** Pages anyone may read. */ const OPEN_PATHS = ['/imprint', '/privacy', '/terms'] export default defineNuxtRouteMiddleware((to) => { const loggedIn = gameAuth.token() !== null if (OPEN_PATHS.includes(to.path)) return const isGuest = GUEST_PATHS.includes(to.path) if (!loggedIn && !isGuest) return navigateTo('/login') if (loggedIn && isGuest) return navigateTo('/worlds') })