Skip to content

feat: support binding dev server to all network interfaces via --host#11

Closed
hackxixi wants to merge 2 commits into
PeakCode-AI:mainfrom
hackxixi:dev
Closed

feat: support binding dev server to all network interfaces via --host#11
hackxixi wants to merge 2 commits into
PeakCode-AI:mainfrom
hackxixi:dev

Conversation

@hackxixi

Copy link
Copy Markdown

Summary

  • Add PEAKCODE_HOST and VITE_WS_PORT to turbo.json globalEnv so Turbo passes them through to Vite and the server processes
  • Read PEAKCODE_HOST in vite.config.ts to bind Vite's dev server to the configured interface (default: localhost)
  • When binding to a wildcard address (0.0.0.0 / ::), inject VITE_WS_PORT instead of hardcoding [::1] into VITE_WS_URL, so the browser constructs the WebSocket URL from window.location.hostname + the correct server port
  • Fix bug in wsTransport.ts: fallback URL was using window.location.port (Vite port 5733) instead of the WS server port (3773), breaking WebSocket connections when accessed from external hosts
  • Add VITE_WS_URL and VITE_WS_PORT to ImportMetaEnv type declarations

Usage

bun run dev -- --host 0.0.0.0

Test plan

  • bun run dev (no flags) still binds to localhost only — behaviour unchanged
  • bun run dev -- --host 0.0.0.0 binds both Vite (5733) and the WS server (3773) to 0.0.0.0
  • Accessing the app from another device on the LAN connects successfully and the WebSocket handshake completes
  • bun fmt && bun lint && bun run typecheck pass

https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC

- Pass PEAKCODE_HOST and VITE_WS_PORT through turbo globalEnv so child
  processes (Vite, server) receive the host configuration
- Read PEAKCODE_HOST in vite.config.ts to bind Vite's dev server to the
  configured interface instead of always defaulting to localhost
- Inject VITE_WS_PORT when binding to a wildcard address (0.0.0.0 / ::)
  so the browser can construct the correct WS URL from
  window.location.hostname + the server port, rather than a hardcoded
  loopback address
- Fix wsTransport.ts fallback URL: was using window.location.port (Vite
  port 5733) instead of the WS server port (3773), breaking external
  connections
- Add VITE_WS_URL and VITE_WS_PORT to ImportMetaEnv type declarations

Usage: bun run dev -- --host 0.0.0.0

Claude-Session: https://claude.ai/code/session_01B95xcqmnLyWiAhApQdjtLC
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M labels Jun 18, 2026
- Update resolved package entries to use registry.npmmirror.com tarball URLs
- Keep lockfile checksums and package metadata unchanged
@github-actions github-actions Bot added size:XXL and removed size:M labels Jun 18, 2026
@jwangkun

Copy link
Copy Markdown
Collaborator

感谢这个 PR @hackxixi,支持 --host 绑定网卡的需求是合理的,代码改动本身(vite.config / wsTransport 端口 bug 修复 / dev-runner 的 wildcard 处理)质量也不错 👍

但是这个 PR 目前没法合并,核心问题是 bun.lock 被本地 npm 镜像污染了:

这个 PR 有 +1333/−1306 的改动,其中 1303 行删除全部来自 bun.lock。进一步看 diff,bun.lock 里每个包的解析地址被从空字符串改成了 https://registry.npmmirror.com/...:

- "@anthropic-ai/claude-agent-sdk": [..., "", ...]
+ "@anthropic-ai/claude-agent-sdk": [..., "https://registry.npmmirror.com/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.2.112.tgz", ...]

这会把贡献者本地的 npmmirror 镜像源固化进仓库,影响所有其他开发者的依赖解析,属于 lockfile drift,不能合入。

如果你愿意重新提交,建议这样做:

  1. 基于最新 main 重新开分支(main 已经有较多更新)。
  2. 只保留代码改动(vite.config.tswsTransport.tsdev-runner.tsvite-env.d.tsturbo.json),不要提交 bun.lock 的改动(或者用官方源重新 bun install 生成一份干净的 lockfile)。
  3. 重新开一个聚焦的 PR。

整理好之后欢迎再提,这个功能是有价值的 🙏

@jwangkun jwangkun closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants