diff --git a/src/public/index.html b/src/public/index.html index b88c2fd..5121e75 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -4340,9 +4340,11 @@ function connectWebSocket() { // Determine WebSocket URL - use same hostname as current page, port 8081 const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsHost = window.location.hostname; - const wsPort = '8081'; - const wsUrl = `${wsProtocol}//${wsHost}:${wsPort}`; + // Heuristic: if running on localhost, use port 8081; otherwise use /ws path via Nginx + const isLocalhost = location.hostname === 'localhost' || location.hostname === '127.0.0.1'; + const wsUrl = isLocalhost + ? `${wsProtocol}//${location.hostname}:8081` + : `${wsProtocol}//${location.host}/ws`; console.log('Connecting to WebSocket:', wsUrl); ws = new WebSocket(wsUrl);