import { useAuthStore } from "#imports"; export default defineNuxtRouteMiddleware(async (to, from) => { const authStore = useAuthStore(); const config = useRuntimeConfig(); // if (to.path == '/') { // const code = to.query.code // if (code) { // if (!Array.isArray(code)) { // try { // await oauth2_register_discord(code) // return navigateTo('/lobby') // } catch { // return navigateTo('/login') // } // } else { // return navigateTo('/login') // } // } // return navigateTo("/lobby") // } // if (!goStore.discordId) { // const heron_session = useCookie('heron_session') // if (!heron_session.value) { return navigateTo('/login') } // try { // await heron_cookie_login(heron_session.value) // if (to.path == '/') { // return navigateTo("/lobby") // } // } catch { // return navigateTo('/login') // } // } if (to.path.startsWith("/game")) { return; } if (to.path == "/login") { return; } if (to.path == "/lobby") { return; } if (to.path == "/rules") { return; } if (to.path == "/test") { return; } // In a real app you would probably not redirect every route to `/` // however it is important to check `to.path` before redirecting or you // might get an infinite redirect loop if (to.path !== "/") { return navigateTo("/"); } return navigateTo("/lobby"); });