Skip to content

🙌 OpenHands: AI-Driven Development

Fix: Update WebSocket URL to use correct protocol from window.location (#1900)

மனோஜ்குமார் பழனிச்சாமிec7be6ee51f2
diff --git a/frontend/src/services/socket.ts b/frontend/src/services/socket.ts
index 7b5b97337a..981c259783 100644
--- a/frontend/src/services/socket.ts
+++ b/frontend/src/services/socket.ts
@@ -41,7 +41,8 @@ class Socket {
private static _initialize(token: string): void {
if (Socket.isConnected()) return;
- const WS_URL = `ws://${window.location.host}/ws?token=${token}`;
+ const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
+ const WS_URL = `${protocol}//${window.location.host}/ws?token=${token}`;
Socket._socket = new WebSocket(WS_URL);
Socket._socket.onopen = (e) => {