Works on PROD

This commit is contained in:
aodulov
2025-10-15 16:07:56 +03:00
parent 03d31011fd
commit 8cbb520408
7 changed files with 38 additions and 9 deletions

View File

@@ -1,3 +1,13 @@
// Define the runtime configuration interface
interface RuntimeConfig {
API_URL: string;
}
declare global {
interface Window {
runtimeConfig?: RuntimeConfig;
}
}
class WebSocketService {
private ws: WebSocket | null = null;
private messageHandlers: ((message: any) => void)[] = [];
@@ -14,7 +24,8 @@ class WebSocketService {
this.currentSessionId = sessionId;
this.currentClientId = clientId;
const apiUrl = process.env.REACT_APP_API_URL || 'ws://localhost:8000';
// Read the API_URL from the runtime configuration
const apiUrl = window.runtimeConfig?.API_URL || 'ws://localhost:8000';
const wsUrl = `${apiUrl.replace(/^http/, 'ws')}/sessions/${sessionId}`;
this.ws = new WebSocket(wsUrl);