From f7fdc34af14ece511c5d3403d58eb29a64d10642 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Fri, 1 May 2026 10:25:34 -0700 Subject: [PATCH] docs(prompt): tighten Vite HMR config to match verified-working shape Spike on 2026-05-01 confirmed HMR works end-to-end through Traefik when ALL of these are set: server: { host: '0.0.0.0', port: <3000-3009>, strictPort: true, hmr: { clientPort: 443, protocol: 'wss', host: '' }, } The previous prompt omitted hmr.host, which lets Vite's HMR client guess the wrong host and silently fail the WS upgrade. Adding the host explicitly. Verified test: 101 Switching Protocols, vite-hmr subprotocol negotiated, js-update messages fire within ~1s. Co-authored-by: Cursor --- app/api/chat/route.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 11cd97f2..f60f6e34 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -173,8 +173,8 @@ Each project has a persistent \`vibn-dev\` container. Edit files via \`fs_*\` an - \`dev_server_stop\` / \`dev_server_list\` / \`dev_server_logs\`. On \`code: PORT_BUSY\`, stop the existing server or pick a different 3000–3009 port — don't blindly retry. **HMR through the proxy (apply when scaffolding):** -- **Vite:** \`server.host: '0.0.0.0'\`, \`server.hmr.clientPort: 443\`, \`server.hmr.protocol: 'wss'\`. Default localhost binding looks fine locally but breaks HMR through Traefik. -- **Next dev:** \`next dev -p 3000 -H 0.0.0.0\` (WSS HMR works automatically). +- **Vite (verified working):** in \`vite.config\` set \`server: { host: '0.0.0.0', port: <3000-3009>, strictPort: true, hmr: { clientPort: 443, protocol: 'wss', host: '' } }\`. The \`hmr.host\` is REQUIRED — without it Vite's HMR client can guess the wrong host and the WS handshake fails through Traefik. Default localhost binding looks fine locally but breaks HMR through the proxy. +- **Next dev:** \`next dev -p 3000 -H 0.0.0.0\` (WSS HMR works automatically through the proxy without extra config). - **Express / plain Node:** bind \`0.0.0.0\` (we set \`HOST=0.0.0.0\` env, but verify your framework respects it). **Build-me-X recipe:** \`devcontainer_ensure\` → \`shell_exec npx create-next-app@latest . --yes\` (or pick an OSS scaffold via \`github_search\`) → \`fs_edit\` / \`fs_write\` to customize → \`dev_server_start { command: 'npm run dev', port: 3000 }\` and share the preview URL → when the user says "ship it", call \`ship { projectId, commitMsg }\` (commits to Gitea and triggers prod deploy in one shot).