const validPaths = ["/", "/rules", "/test", "/words"]; export default defineNuxtRouteMiddleware(async (to, from) => { const config = useRuntimeConfig(); if (to.path.startsWith("/game/")) { return; } if (to.path == "/login") { const code = to.query.code; if (!code) { navigateTo(config.public.discordLoginEndpoint, { external: true }); } else { navigateTo("/login"); } return; } if (validPaths.includes(to.path)) { return; } if (to.path !== "/") { return navigateTo("/"); } });