diff --git a/web/core/components/pages/editor/editor-body.tsx b/web/core/components/pages/editor/editor-body.tsx index c4efaac7bfe..faa967b7efa 100644 --- a/web/core/components/pages/editor/editor-body.tsx +++ b/web/core/components/pages/editor/editor-body.tsx @@ -115,11 +115,11 @@ export const PageEditorBody: React.FC = observer((props) => { const realtimeConfig: TRealtimeConfig | undefined = useMemo(() => { // Construct the WebSocket Collaboration URL try { - const LIVE_SERVER_BASE_URL = LIVE_BASE_URL ?? window.location.origin; - const WS_LIVE_URL = new URL(`${LIVE_SERVER_BASE_URL}${LIVE_BASE_PATH}`); + const LIVE_SERVER_BASE_URL = LIVE_BASE_URL?.trim() || window.location.origin; + const WS_LIVE_URL = new URL(LIVE_SERVER_BASE_URL); const isSecureEnvironment = window.location.protocol === "https:"; WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws"; - WS_LIVE_URL.pathname = "collaboration"; + WS_LIVE_URL.pathname = `${LIVE_BASE_PATH}/collaboration`; // Construct realtime config return { url: WS_LIVE_URL.toString(),