fix(ui): WebSocket protocol matches page protocol, not hostname (#272)

buildWsUrl() forced wss:// on non-localhost HTTP connections,
breaking LAN/Docker deployments at http://192.168.x.x:3000.
Now simply: https → wss, http → ws.

Closes #272

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
ruv 2026-03-16 11:35:11 -04:00
parent 7eba8c7286
commit 578d84c25e

View file

@ -113,11 +113,11 @@ export function buildApiUrl(endpoint, params = {}) {
// Helper function to build WebSocket URLs
export function buildWsUrl(endpoint, params = {}) {
// Use secure WebSocket (wss://) when serving over HTTPS or on non-localhost
// Use ws:// only for localhost development
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
// Match WebSocket protocol to page protocol: https → wss, http → ws.
// Previous logic forced wss:// on non-localhost HTTP, breaking LAN/Docker
// deployments served over plain HTTP. See issue #272.
const isSecure = window.location.protocol === 'https:';
const protocol = (isSecure || !isLocalhost)
const protocol = isSecure
? API_CONFIG.WSS_PREFIX
: API_CONFIG.WS_PREFIX;