diff --git a/frontend/src/models/system.js b/frontend/src/models/system.js index c64ac66a..f248d4f9 100644 --- a/frontend/src/models/system.js +++ b/frontend/src/models/system.js @@ -1,4 +1,4 @@ -import { API_BASE, AUTH_TIMESTAMP } from "@/utils/constants"; +import { API_BASE, AUTH_TIMESTAMP, fullApiUrl } from "@/utils/constants"; import { baseHeaders } from "@/utils/request"; import DataConnector from "./dataConnector"; @@ -10,7 +10,7 @@ const System = { .catch(() => false); }, totalIndexes: async function (slug = null) { - const url = new URL(`${API_BASE}/system/system-vectors`); + const url = new URL(`${fullApiUrl()}/system/system-vectors`); if (!!slug) url.searchParams.append("slug", encodeURIComponent(slug)); return await fetch(url.toString(), { headers: baseHeaders(), diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 11b8da97..2fde1ee0 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -7,3 +7,8 @@ export const COMPLETE_QUESTIONNAIRE = "anythingllm_completed_questionnaire"; export const USER_BACKGROUND_COLOR = "bg-historical-msg-user"; export const AI_BACKGROUND_COLOR = "bg-historical-msg-system"; + +export function fullApiUrl() { + if (API_BASE !== "/api") return API_BASE; + return `${window.location.origin}/api`; +}