Description
Is there an easy way to NOT allow logged in users to access the login/register pages? Once the user is logged in there should be no reason to access those pages, instead they should be redirected to the index page.('/')
Ive tried adding route redirects in the nuxt.config as well as adding a middleware to the login/register pages butt he page is accessed first for a few seconds before it gets redirected to the index page ('/').
loggedIn.ts middleware
export default defineNuxtRouteMiddleware(async (to, from) => { const user = useSupabaseUser(); if (user.value) return navigateTo('/'); });
This is not working as expected because it seems there is a few second delay on page load when user accesses the url directly and when the redirect(navigateTo) is fired.