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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -115,11 +115,11 @@ export const PageEditorBody: React.FC<Props> = observer((props) => {
const realtimeConfig: TRealtimeConfig | undefined = useMemo(() => { const realtimeConfig: TRealtimeConfig | undefined = useMemo(() => {
// Construct the WebSocket Collaboration URL // Construct the WebSocket Collaboration URL
try { try {
const LIVE_SERVER_BASE_URL = LIVE_BASE_URL ?? window.location.origin; const LIVE_SERVER_BASE_URL = LIVE_BASE_URL?.trim() || window.location.origin;
const WS_LIVE_URL = new URL(`${LIVE_SERVER_BASE_URL}${LIVE_BASE_PATH}`); const WS_LIVE_URL = new URL(LIVE_SERVER_BASE_URL);
const isSecureEnvironment = window.location.protocol === "https:"; const isSecureEnvironment = window.location.protocol === "https:";
WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws"; WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws";
WS_LIVE_URL.pathname = "collaboration"; WS_LIVE_URL.pathname = `${LIVE_BASE_PATH}/collaboration`;
// Construct realtime config // Construct realtime config
return { return {
url: WS_LIVE_URL.toString(), url: WS_LIVE_URL.toString(),