Works on PROD
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user