Ver Fonte

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

மனோஜ்குமார் பழனிச்சாமி há 1 ano atrás
pai
commit
ec7be6ee51
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      frontend/src/services/socket.ts

+ 2 - 1
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) => {