From f22dfbd0656d0c1c9b8c22be08d505564323f75d Mon Sep 17 00:00:00 2001 From: Shanmuga Krishnan S M Date: Mon, 27 Jul 2026 14:37:26 +0530 Subject: [PATCH] Support VITE_API_URL and VITE_CHATBOT_URL environment variables for hosted builds --- src/lib/utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5fa9fc6..776f3be 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -22,11 +22,19 @@ export function truncate(str: string, n: number): string { } export const getBackendUrl = (path: string = ''): string => { + const envUrl = import.meta.env.VITE_API_URL; + if (envUrl) { + return `${envUrl.endsWith('/') ? envUrl.slice(0, -1) : envUrl}${path}`; + } const host = window.location.hostname; return `http://${host}:8085${path}`; }; export const getChatbotUrl = (path: string = ''): string => { + const envUrl = import.meta.env.VITE_CHATBOT_URL; + if (envUrl) { + return `${envUrl.endsWith('/') ? envUrl.slice(0, -1) : envUrl}${path}`; + } const host = window.location.hostname; return `http://${host}:8081${path}`; };