fix: WebSocket wss:// same-origin URL + try/catch to prevent crash on HTTPS

- Change DEFAULT_WS_URL from ws://hostname:3001 to wss://window.location.host
- Wrap WebSocket constructor in try/catch to prevent React crash on connection error
- Fixes white page when opening a project (CADEditor crashed on insecure ws:// from HTTPS page)
This commit is contained in:
2026-06-26 17:58:06 +02:00
parent 1bcfaffdd4
commit 6d15a692af
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ export interface UseYjsBindingResult {
clearSelection: () => void;
}
const DEFAULT_WS_URL = `ws://${window.location.hostname}:3001`;
const DEFAULT_WS_URL = `wss://${window.location.host}`;
export function useYjsBinding(opts: UseYjsBindingOptions): UseYjsBindingResult {
const { docName, wsUrl = DEFAULT_WS_URL, userId, userName, userColor, enabled = true } = opts;