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)