Hello, I was wondering what is the best way to verify if user is logged in before showing route, I am doing a basic test right now via localStorage variable in real life I would have my state in local storage or global store saying i am logged in with an http cookie.
export default defineNuxtRouteMiddleware((to, from) => { if (import.meta.server) return; console.log(localStorage.getItem('loggedIn')); if (localStorage.getItem('loggedIn') !== 'true') { return navigateTo('/sign-in'); }});
export default defineNuxtRouteMiddleware((to, from) => { if (import.meta.server) return; console.log(localStorage.getItem('loggedIn')); if (localStorage.getItem('loggedIn') !== 'true') { return navigateTo('/sign-in'); }});
Is there a way so the user is not even able to see the other page before the redirect?
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community