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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user