Browse Source

feat: add /socket.io path configuration for client-side websocket settings (#896)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 month ago
parent
commit
558121df72
1 changed files with 8 additions and 2 deletions
  1. 8 2
      client/src/context/hooks/useWebSocket.ts

+ 8 - 2
client/src/context/hooks/useWebSocket.ts

@@ -31,14 +31,20 @@ export const useWebSocket = ({
       const extraHeaders = {
       const extraHeaders = {
         'milvus-client-id': clientId,
         'milvus-client-id': clientId,
       };
       };
-      const ioParams = { extraHeaders, query: extraHeaders };
 
 
       // Ensure previous connection is cleaned up before creating a new one
       // Ensure previous connection is cleaned up before creating a new one
       if (socket.current) {
       if (socket.current) {
         clearSocket();
         clearSocket();
       }
       }
 
 
-      socket.current = isElectron ? io(url as string, ioParams) : io(ioParams);
+      // For Electron, use default config, for web use path configuration
+      socket.current = isElectron
+        ? io(url as string, { extraHeaders, query: extraHeaders })
+        : io(url as string, {
+            extraHeaders,
+            query: extraHeaders,
+            path: '/socket.io', // Add path configuration for proxy usage
+          });
 
 
       socket.current.on('connect', () => {
       socket.current.on('connect', () => {
         // console.info('--- ws connected ---', clientId);
         // console.info('--- ws connected ---', clientId);