Ihti.
Ihti.
NNuxt
Created by Ihti. on 11/9/2024 in #❓・help
middleware redirecting to authentification login but user is connected and cookie token is logged
Hello, I am doing my own authentification system with cookies, but i developed a middleware for protect pages, page for only user logged The problem is the user is logged but is redirecting to login, and when i console log they logging "cookie finded! not redirection"
export default defineNuxtRouteMiddleware(async (to, from) => {
const authCookie = useCookie('auth_token');

if (!authCookie.value) {
console.log('redirecting to login');
return navigateTo('/dashboard/auth/login');
} else {
console.log('cookie finded! not redirection');
}
});
export default defineNuxtRouteMiddleware(async (to, from) => {
const authCookie = useCookie('auth_token');

if (!authCookie.value) {
console.log('redirecting to login');
return navigateTo('/dashboard/auth/login');
} else {
console.log('cookie finded! not redirection');
}
});
60 replies