Skip to content
Snippets Groups Projects
Unverified Commit 83a648df authored by Huu Le's avatar Huu Le Committed by GitHub
Browse files

chore: add use window.ENV.BASE_URL as backendOrigin (#205)


---------
Co-authored-by: default avatarMarcus Schiesser <mail@marcusschiesser.de>
parent dcf52abd
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,15 @@ export function useClientConfig(): ChatConfig {
const [config, setConfig] = useState<ChatConfig>();
const backendOrigin = useMemo(() => {
return chatAPI ? new URL(chatAPI).origin : "";
if (chatAPI) {
return new URL(chatAPI).origin;
} else {
if (typeof window !== "undefined") {
// Use BASE_URL from window.ENV
return (window as any).ENV?.BASE_URL || "";
}
return "";
}
}, [chatAPI]);
const configAPI = `${backendOrigin}/api/chat/config`;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment