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 } + +