diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index 80e97a73e..a4af5e6a4 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -1,4 +1,4 @@ -import { AxiosResponse } from "axios"; +import axios, { AxiosResponse } from "axios"; import { ReactFlowJsonObject } from "reactflow"; import { BASE_URL_API } from "../../constants/constants"; import { api } from "../../controllers/API/api"; @@ -146,8 +146,8 @@ export async function updateFlowInDatabase( description: updatedFlow.description, }); - if (response.status !== 200) { - throw new Error(`HTTP error! status: ${response.status}`); + if (response?.status !== 200) { + throw new Error(`HTTP error! status: ${response?.status}`); } return response.data; } catch (error) { @@ -522,4 +522,4 @@ export async function deleteApiKey(api_key: string) { console.log("Error:", error); throw error; } -} +} \ No newline at end of file diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 89c7919af..49a03af57 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -156,6 +156,13 @@ export default function FormModal({ function handleOnClose(event: CloseEvent): void { if (isOpen.current) { + //check if the user has been logged out, if so close the chat when the user is redirected to the login page + if (window.location.href.includes("login")) { + setOpen(false); + ws.current?.close(); + return; + } + getBuildStatus(flow.id) .then((response) => { if (response.data.built) {