fix(dev): evita problemi IPv6 di localhost su ws e proxy controller

Usa fallback a 127.0.0.1 quando l'hostname è localhost/::1 nei client websocket display/controller.

Instrada il proxy del controller dev verso Vite tramite DEV_PROXY_HOST (default 127.0.0.1).

Mostra gli URL locali del server con 127.0.0.1 per una diagnostica coerente su Raspberry/Linux.
This commit is contained in:
2026-02-11 00:52:06 +01:00
parent ad7a8575c6
commit 917850502d
4 changed files with 18 additions and 7 deletions

View File

@@ -312,7 +312,12 @@ export default {
// 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 defaultHost = (
location.hostname === 'localhost' || location.hostname === '::1'
)
? `127.0.0.1${location.port ? `:${location.port}` : ''}`
: location.host
const wsHost = params.get('wsHost') || defaultHost
const wsUrl = `${protocol}//${wsHost}/ws`
console.log('[Controller] Connecting to WebSocket:', wsUrl)

View File

@@ -225,7 +225,12 @@ export default {
// 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 defaultHost = (
location.hostname === 'localhost' || location.hostname === '::1'
)
? `127.0.0.1${location.port ? `:${location.port}` : ''}`
: location.host
const wsHost = params.get('wsHost') || defaultHost
const wsUrl = `${protocol}//${wsHost}/ws`
console.log('[Display] Connecting to WebSocket:', wsUrl)

View File

@@ -32,8 +32,8 @@ export function printServerInfo(displayPort = 5173, controllerPort = 3001) {
const networkIPs = getNetworkIPs()
console.log(`\nSegnapunti Server`)
console.log(` Display: http://localhost:${displayPort}/`)
console.log(` Controller: http://localhost:${controllerPort}/`)
console.log(` Display: http://127.0.0.1:${displayPort}/`)
console.log(` Controller: http://127.0.0.1:${controllerPort}/`)
if (networkIPs.length > 0) {
console.log(`\n Controller da dispositivi remoti:`)