Rank 2: Process
Hi all,
I try to build a webapp which uses SSR and the Appwrite Auth to Login. I found some Templates which uses H3 for Session mgmt. But I can't get it to work with my middleware. Maybe someone did this already and can me push in the right direction. I use Pinia to save the User data after login in, but reload of cause the pinia store is cleared. It works only after direct login and handling of the middleware on client side.
I have a middleware which checks if the session right now is not expired.
import { useUserStore } from "~/stores/userStore";
export default defineNuxtRouteMiddleware(async (to, from) => { const authStore = useUserStore(); if (authStore.user) { const sessionStatus = await authStore.checkSession(authStore.user.$id); if (!sessionStatus) { return navigateTo("/login"); } } else { return navigateTo("/login"); }});If this is more a Nuxt topic and wrong in this place. Im sorry and please close this.
Thanks a lot.