diff --git a/frontend/composables/use-api.ts b/frontend/composables/use-api.ts index 2eb4f88..5f8dde8 100644 --- a/frontend/composables/use-api.ts +++ b/frontend/composables/use-api.ts @@ -36,9 +36,6 @@ export function useUserApi(): UserClient { if (r.status === 401) { console.error("unauthorized request, invalidating session"); authCtx.invalidateSession(); - if (window.location.pathname !== "/") { - window.location.href = "/"; - } } }); diff --git a/frontend/composables/use-auth-context.ts b/frontend/composables/use-auth-context.ts index 740a303..883a0be 100644 --- a/frontend/composables/use-auth-context.ts +++ b/frontend/composables/use-auth-context.ts @@ -71,6 +71,7 @@ class AuthContext implements IAuthContext { } isAuthorized() { + console.debug("isAuthorized", this.token); return this.token; } diff --git a/frontend/middleware/auth.ts b/frontend/middleware/auth.ts index 2eca73f..97a9920 100644 --- a/frontend/middleware/auth.ts +++ b/frontend/middleware/auth.ts @@ -4,6 +4,7 @@ export default defineNuxtRouteMiddleware(async () => { if (!ctx.isAuthorized()) { if (window.location.pathname !== "/") { + console.debug("[middleware/auth] isAuthorized returned false, redirecting to /"); return navigateTo("/"); } } @@ -13,6 +14,7 @@ export default defineNuxtRouteMiddleware(async () => { const { data, error } = await api.user.self(); if (error) { if (window.location.pathname !== "/") { + console.debug("[middleware/user] user is null and fetch failed, redirecting to /"); return navigateTo("/"); } }