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: '<previewUrl 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 <cursoragent@cursor.com>
This commit is contained in:
2026-05-01 10:25:34 -07:00
parent 41f5f02c68
commit f7fdc34af1

View File

@@ -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 30003009 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 previewUrl host, no protocol>' } }\`. 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).