From bc160bc8fbd3d3bb4f80ef98a4a7564e84455b94 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Tue, 28 Nov 2023 15:38:08 +0100 Subject: [PATCH] fix: session expiration bug --- agenta-web/src/lib/helpers/axiosConfig.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agenta-web/src/lib/helpers/axiosConfig.ts b/agenta-web/src/lib/helpers/axiosConfig.ts index 8b5af0486b..8829470c38 100644 --- a/agenta-web/src/lib/helpers/axiosConfig.ts +++ b/agenta-web/src/lib/helpers/axiosConfig.ts @@ -1,5 +1,7 @@ import axiosApi from "axios" import {getErrorMessage, globalErrorHandler} from "./errorHandler" +import {signOut} from "supertokens-auth-react/recipe/thirdpartypasswordless" +import router from "next/router" const axios = axiosApi.create({ headers: { @@ -20,6 +22,14 @@ axios.interceptors.response.use( }` error.message = msg + if (error.response?.status === 401) { + signOut() + .then(() => { + router.push("/auth") + }) + .catch(console.error) + } + globalErrorHandler(error) throw error