feat: expose `websocketPort` config option for reverse proxy compatibility
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- devtools, networking
Línea de trabajo
Comienza con packages/core/src/node/config.ts y packages/core/src/node/plugins/server.ts, después inspecciona createDevToolsMiddleware y la opción portWebSocket existente en packages/core/src/node/ws.ts. Añade el flujo de configuración de websocketPort descrito en el issue y verifica que un puerto fijo llegue al servidor WebSocket para la configuración del proxy.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Clear and concise description of the problem
When the Vite dev server sits behind a reverse proxy (Caddy, nginx, etc.), the DevTools WebSocket connection fails. The proxy forwards HTTP traffic to Vite's main server port, but DevTools opens its own WebSocket server on a random port that the proxy doesn't know about.
createWsServer in packages/core/src/node/ws.ts picks the port with:
The client reads /.devtools/.connection.json, gets {"backend":"websocket","websocket":62480} (or whatever random port was chosen), and tries to connect directly to that port. Through the proxy, this fails silently.
In my local dev environment, I use caddy to help simulate HTTPS and to have a more "production like" networking experience while still having HMR and other conveniences.
Suggested solution
Add a websocketPort option to DevToolsConfig in packages/core/src/node/config.ts and wire it through to createDevToolsMiddleware.
The internal plumbing already supports it — CreateWsServerOptions already accepts portWebSocket. It's just not exposed through the config or passed by DevToolsServer in packages/core/src/node/plugins/server.ts.
The change would be:
- Add
websocketPort?: numbertoDevToolsConfig - Include it in
normalizeDevToolsConfig - In
DevToolsServer.configureServer, read it from the resolved config and pass it asportWebSockettocreateDevToolsMiddleware
Usage:
// vite.config.ts
export default defineConfig({
devtools: {
enabled: true,
websocketPort: 7812,
},
})
With a fixed port, users can configure their proxy to forward that port alongside Vite's main port.
Alternative
DevTools could reuse Vite's existing HMR WebSocket connection instead of opening a separate server. This would make it work behind any proxy that already supports Vite's dev server with no extra config. That's a much larger architectural change though — a config option for the port is a simpler path.
Additional context
In the meantime I have made for myself a small Vite plugin that intercepts requests to the DevTools inject script and returns an empty module when the Host header isn't localhost. This means DevTools only works on localhost — not through the proxy. Otherwise I will end up seeing Vite DevTools but would never be able to authenticate because it could never trigger an auth flow for me to see on the terminal.
As a side note:
The "Code of Conduct" link goes to a 404 but I checked it anyways.
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.2k
- Forks
- 89
- Merge medio
- 18 h 46 min
- PR fusionados (30 d)
- 24
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de vitejs/devtools
-
enhancement
-
pending triage
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
-
pending triage
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
DevTools error page origin Abiertopending triage
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
Todos los issues de vitejs/devtools
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
copse-dev/agent-pane#2953 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Abiertobug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Client support matrix inclusion Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
calcite-components needs triage refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Esri/calcite-design-system#15203 ·