NuxtN
Nuxt14mo ago
Artist201

Global middleware only runs once on client side ?

Hello there,
Hope you all doing well.

am trying to force a user on a password reset page based on their login token. the password reset flag is working fine.
But my issues are :
server side middleware redirect only works the first time the page is opened. then the user can navigate (though any usefetch will be returining 500 now )

i tried then to add a frontend middleware, but this is also only triggered once and never triggers when the user tries to navigate to other pages
export default defineNuxtRouteMiddleware((to, from) => {
    const userStore = useUserStore();
    const {resetPassword} = storeToRefs(userStore);
    if(resetPassword && !(to.fullPath == '/passResetPath' || to.fullPath == '/passResetPath/')){
        navigateTo('/passResetPath',{ redirectCode: 301 })
    }
});
Was this page helpful?