fix: live base server url. (#5734)

* fix: live base server url.

* chore: update websocket URL logic.
This commit is contained in:
Prateek Shourya
2024-10-03 14:06:03 +05:30
committed by GitHub
parent 62c45f3bb1
commit c90df623de

View File

@@ -115,11 +115,11 @@ export const PageEditorBody: React.FC<Props> = 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(),