From 41dc1d99889e65f51d26d611649e47b4010463cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Blomberg?= Date: Fri, 10 Apr 2026 18:56:26 +0200 Subject: [PATCH] fix: handle UNAUTHORIZED responses by clearing session and reloading --- frontend/src/lib/gql.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/gql.ts b/frontend/src/lib/gql.ts index 0fac19b..467e11a 100644 --- a/frontend/src/lib/gql.ts +++ b/frontend/src/lib/gql.ts @@ -16,9 +16,16 @@ export async function gql( body: JSON.stringify({ query, variables }), }) - const json = await res.json() + const json = await res.json() if (json.errors?.length) { + if (json.errors[0].message === 'UNAUTHORIZED') { + localStorage.removeItem('token') + localStorage.removeItem('username') + window.location.href = '/' + } throw new Error(json.errors[0].message) } return json.data as T } + +