Skip to content

Commit 2847b2e

Browse files
committed
fix the web socket connection issue
Signed-off-by: Naymul Islam <naymul504@gmail.com>
1 parent d0ab67f commit 2847b2e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

frontend/src/services/WebSocketManager.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export class WebSocketManager {
1313
this.websocket.close();
1414
}
1515

16-
const wsBase = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}`;
16+
// Detect if we're in development mode (frontend on different port than backend)
17+
const isDev = window.location.port === '5173';
18+
const backendHost = isDev ? 'localhost:8000' : window.location.host;
19+
const wsBase = `${window.location.protocol === "https:" ? "wss" : "ws"}://${backendHost}`;
1720
console.log(`📡 Connecting to WebSocket: ${wsBase}/ws/${jobId}`);
1821
this.websocket = new WebSocket(`${wsBase}/ws/${jobId}`);
1922

@@ -89,7 +92,10 @@ export class WebSocketManager {
8992
this.streamWebSocket.close();
9093
}
9194

92-
const wsBase = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}`;
95+
// Detect if we're in development mode (frontend on different port than backend)
96+
const isDev = window.location.port === '5173';
97+
const backendHost = isDev ? 'localhost:8000' : window.location.host;
98+
const wsBase = `${window.location.protocol === "https:" ? "wss" : "ws"}://${backendHost}`;
9399
console.log(`🎥 Connecting to Stream WebSocket: ${wsBase}/stream/${jobId}`);
94100
this.streamWebSocket = new WebSocket(`${wsBase}/stream/${jobId}`);
95101

0 commit comments

Comments
 (0)