From 600ad232e164332d10440fb696d235dca68a5c65 Mon Sep 17 00:00:00 2001 From: hjlarry Date: Sat, 20 Sep 2025 12:14:56 +0800 Subject: [PATCH] fix config --- .../workflow/collaboration/core/websocket-manager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/collaboration/core/websocket-manager.ts b/web/app/components/workflow/collaboration/core/websocket-manager.ts index b5d63c04d2..cbcc04fb1b 100644 --- a/web/app/components/workflow/collaboration/core/websocket-manager.ts +++ b/web/app/components/workflow/collaboration/core/websocket-manager.ts @@ -8,8 +8,14 @@ export class WebSocketClient { private config: WebSocketConfig constructor(config: WebSocketConfig = {}) { + const inferUrl = () => { + if (typeof window === 'undefined') + return 'ws://localhost:5001' + const scheme = window.location.protocol === 'https:' ? 'wss:' : 'ws:' + return `${scheme}//${window.location.host}` + } this.config = { - url: config.url || process.env.NEXT_PUBLIC_SOCKET_URL || 'ws://localhost:5001', + url: config.url || process.env.NEXT_PUBLIC_SOCKET_URL || inferUrl(), transports: config.transports || ['websocket'], withCredentials: config.withCredentials !== false, ...config,