From a62e891fa022c437110794d11a39343bc2b74baf Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Wed, 16 Aug 2023 15:43:46 -0700 Subject: [PATCH] force check api online via JSON response --- frontend/src/models/system.js | 3 ++- frontend/src/utils/constants.js | 3 +-- server/endpoints/system.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/models/system.js b/frontend/src/models/system.js index 9dc84001..d3f0f7e6 100644 --- a/frontend/src/models/system.js +++ b/frontend/src/models/system.js @@ -4,7 +4,8 @@ import { baseHeaders } from "../utils/request"; const System = { ping: async function () { return await fetch(`${API_BASE}/ping`) - .then((res) => res.ok) + .then((res) => res.json()) + .then((res) => res?.online || false) .catch(() => false); }, totalIndexes: async function () { diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 18bb91ef..fe3a2308 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -1,5 +1,4 @@ -export const API_BASE = - import.meta.env.VITE_API_BASE || "/api"; +export const API_BASE = import.meta.env.VITE_API_BASE || "/api"; export const AUTH_USER = "anythingllm_user"; export const AUTH_TOKEN = "anythingllm_authToken"; diff --git a/server/endpoints/system.js b/server/endpoints/system.js index 5adf1446..8b1588a7 100644 --- a/server/endpoints/system.js +++ b/server/endpoints/system.js @@ -40,7 +40,7 @@ function systemEndpoints(app) { if (!app) return; app.get("/ping", (_, response) => { - response.sendStatus(200); + response.status(200).json({ online: true }); }); app.get("/migrate", async (_, response) => {