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