From ca4d2e1e90dc90933fe4b4b579ffa0e6e5718943 Mon Sep 17 00:00:00 2001 From: lolka1333 Date: Sun, 14 Dec 2025 13:14:53 +0100 Subject: [PATCH] refactor: ensure proper WebSocket URL construction by normalizing basePath --- web/assets/js/websocket.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/assets/js/websocket.js b/web/assets/js/websocket.js index 2a551a8a..5b8a3948 100644 --- a/web/assets/js/websocket.js +++ b/web/assets/js/websocket.js @@ -19,7 +19,14 @@ class WebSocketClient { } const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsUrl = `${protocol}//${window.location.host}${this.basePath}ws`; + // Ensure basePath ends with '/' for proper URL construction + let basePath = this.basePath || ''; + if (basePath && !basePath.endsWith('/')) { + basePath += '/'; + } + const wsUrl = `${protocol}//${window.location.host}${basePath}ws`; + + console.log('WebSocket connecting to:', wsUrl, 'basePath:', this.basePath); try { this.ws = new WebSocket(wsUrl);