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:
@@ -4,6 +4,7 @@ import { setupWebSocketHandler } from './src/websocket-handler.js'
|
||||
import { printServerInfo } from './src/server-utils.js'
|
||||
|
||||
const CONTROLLER_PORT = 3001
|
||||
const DEV_PROXY_HOST = process.env.DEV_PROXY_HOST || '127.0.0.1'
|
||||
|
||||
/**
|
||||
* Plugin Vite che integra un server WebSocket per la gestione dello stato di gioco
|
||||
@@ -59,13 +60,13 @@ function startControllerDevServer(vitePort, wss) {
|
||||
// Proxy verso il dev server di Vite
|
||||
const proxyReq = httpRequest(
|
||||
{
|
||||
hostname: 'localhost',
|
||||
hostname: DEV_PROXY_HOST,
|
||||
port: vitePort,
|
||||
path: targetPath,
|
||||
method: req.method,
|
||||
headers: {
|
||||
...req.headers,
|
||||
host: `localhost:${vitePort}`,
|
||||
host: `${DEV_PROXY_HOST}:${vitePort}`,
|
||||
},
|
||||
},
|
||||
(proxyRes) => {
|
||||
@@ -96,7 +97,7 @@ function startControllerDevServer(vitePort, wss) {
|
||||
} else {
|
||||
// Per l'HMR di Vite, proxare l'upgrade WebSocket verso Vite
|
||||
const proxyReq = httpRequest({
|
||||
hostname: 'localhost',
|
||||
hostname: DEV_PROXY_HOST,
|
||||
port: vitePort,
|
||||
path: request.url,
|
||||
method: 'GET',
|
||||
|
||||
Reference in New Issue
Block a user