From a1db6e782de854e1be597e84bf9790f4ad2111f6 Mon Sep 17 00:00:00 2001 From: Fork Less Date: Wed, 24 Jun 2026 20:59:17 +0200 Subject: [PATCH] feat: fully normalize CUSTOM_VITE_WS_URL (strip scheme/path, keep port) --- frontend/src/App.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8fde057..30bf38c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -435,10 +435,15 @@ function App(): JSX.Element { return } - let wsUrl = import.meta.env.CUSTOM_VITE_WS_URL || 'wss://excalidraw.forkless.com' - if (wsUrl && !wsUrl.startsWith('ws://') && !wsUrl.startsWith('wss://')) { - wsUrl = 'wss://' + wsUrl + let rawUrl = import.meta.env.CUSTOM_VITE_WS_URL || 'wss://excalidraw.forkless.com' + try { + const parsed = new URL(rawUrl.startsWith('ws') ? rawUrl.replace(/^ws/, 'http') : rawUrl) + rawUrl = 'wss://' + parsed.host + } catch { + // Bare hostname/IP — prepend wss:// + rawUrl = 'wss://' + rawUrl } + const wsUrl = rawUrl websocketRef.current = new WebSocket(wsUrl)