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:
parent
8c8f340553
commit
264c97b586
1 changed files with 2 additions and 2 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue