From ad7a8575c6f3591fd366798ef43cc4bc36cf3f5a Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Wed, 11 Feb 2026 00:37:31 +0100 Subject: [PATCH] feat(client): aggiungi supporto query parameter wsHost per WebSocket Permette di specificare manualmente l'host del WebSocket tramite il parametro ?wsHost=[host:port], utile per scenari di sviluppo con WSL2 o quando si accede da dispositivi remoti. - Aggiunge parsing del parametro wsHost in DisplayPage e ControllerPage - Mantiene fallback automatico a location.host se non specificato - Migliora diagnostica con log della URL WebSocket effettiva --- src/components/ControllerPage.vue | 9 ++++++++- src/components/DisplayPage.vue | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/ControllerPage.vue b/src/components/ControllerPage.vue index cadc38a..6c49391 100644 --- a/src/components/ControllerPage.vue +++ b/src/components/ControllerPage.vue @@ -308,7 +308,14 @@ export default { this.isConnecting = true const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:' - const wsUrl = `${protocol}//${location.host}/ws` + + // Permette di specificare un host WebSocket alternativo via query parameter + // Utile per scenari WSL2 o development remoto: ?wsHost=192.168.1.100:3001 + const params = new URLSearchParams(location.search) + const wsHost = params.get('wsHost') || location.host + const wsUrl = `${protocol}//${wsHost}/ws` + + console.log('[Controller] Connecting to WebSocket:', wsUrl) try { this.ws = new WebSocket(wsUrl) diff --git a/src/components/DisplayPage.vue b/src/components/DisplayPage.vue index 1476cfc..2a788b4 100644 --- a/src/components/DisplayPage.vue +++ b/src/components/DisplayPage.vue @@ -221,7 +221,14 @@ export default { this.isConnecting = true const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:' - const wsUrl = `${protocol}//${location.host}/ws` + + // Permette di specificare un host WebSocket alternativo via query parameter + // Utile per scenari WSL2 o development remoto: ?wsHost=192.168.1.100:5173 + const params = new URLSearchParams(location.search) + const wsHost = params.get('wsHost') || location.host + const wsUrl = `${protocol}//${wsHost}/ws` + + console.log('[Display] Connecting to WebSocket:', wsUrl) try { this.ws = new WebSocket(wsUrl)