diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 30bf38c..9fb5e03 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -436,9 +436,13 @@ function App(): JSX.Element { } let rawUrl = import.meta.env.CUSTOM_VITE_WS_URL || 'wss://excalidraw.forkless.com' + let scheme = 'wss://' try { - const parsed = new URL(rawUrl.startsWith('ws') ? rawUrl.replace(/^ws/, 'http') : rawUrl) - rawUrl = 'wss://' + parsed.host + let parseable = rawUrl + if (rawUrl.startsWith('ws://')) { scheme = 'ws://'; parseable = rawUrl.replace(/^ws:\/\//, 'http://') } + else if (rawUrl.startsWith('wss://')) { parseable = rawUrl.replace(/^wss:\/\//, 'https://') } + const parsed = new URL(parseable) + rawUrl = scheme + parsed.host } catch { // Bare hostname/IP — prepend wss:// rawUrl = 'wss://' + rawUrl