Fix server redirectng to login when logged in

When rendering on the server the session is not eagerly loaded when the
authenticated middleware runs, causing it to think the user is not
logged in.  Fix by awaiting the session composable.
This commit is contained in:
Hornwitser 2025-03-09 15:51:00 +01:00
parent 8c8f340553
commit 264c97b586

View file

@ -1,5 +1,5 @@
export default defineNuxtRouteMiddleware((to, from) => {
const { data: session } = useAccountSession();
export default defineNuxtRouteMiddleware(async (to, from) => {
const { data: session } = await useAccountSession();
if (!session.value) {
console.log("Not logged in, redirecting to /login");