[Feature Request] Intercepting hardcoded localhost WebSockets for HMR (.NET Hot Reload / dotnet watch)

未關閉
#7,976 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
typescript

研究方向

該 payload 沒有提到任何 code-server 檔案或測試。首先追蹤瀏覽器內容對輸出的 localhost WebSockets 的處理方式以及內建 Proxy 層,然後檢查注入的 aspnetcore-browser-refresh.js 如何使用暫時性的 ws/wss 連接埠。完成後應該是一個純瀏覽器的 dotnet watch 工作流程,其中 Hot Reload 會透過 code-server 連線,且不會發生 localhost 錯誤。

由索引模型根據 Issue 內容生成。

描述

enhancement

What is your suggestion?

Implement a client-side interceptor or dynamic proxy mechanism within code-server's browser context that can catch outbound WebSocket requests to localhost:<port> and seamlessly route them through code-server's built-in proxy layer back to the remote workspace.

Why do you want this feature?

Developers relying on code-server for a pure browser-based development experience cannot use .NET's Hot Reload (dotnet watch).

When running dotnet watch, the .NET SDK dynamically injects a script (aspnetcore-browser-refresh.js) into the DOM that attempts to establish an HMR WebSocket connection to a random, ephemeral port on localhost (e.g., ws://localhost:40777).

Because the browser executes this locally, it queries the user's physical machine rather than the remote code-server container. The connection drops, and Hot Reload fails:
Firefox can’t establish a connection to the server at ws://localhost:40777/

Image
Firefox can’t establish a connection to the server at ws://localhost:43067/.     aspnetcore-browser-refresh.js:318:25
WebSocket failed to connect.     aspnetcore-browser-refresh.js:19:15
Firefox can’t establish a connection to the server at wss://localhost:33935/.     aspnetcore-browser-refresh.js:318:25
WebSocket failed to connect.     aspnetcore-browser-refresh.js:19:15
Unable to establish a connection to the browser refresh server.     aspnetcore-browser-refresh.js:23:13

Are there any workarounds to get this functionality today?

There are no workarounds for a pure browser workflow (e.g., coding on an iPad or a locked-down laptop without CLI access).

Are you interested in submitting a PR for this?

No, I do not have the familiarity with the code-server networking/proxy codebase to implement this reliably.

主要語言
TypeScript
星號
79.4k
分支
6.9k
平均合併
2 天 13 小時
30 天內合併 PR
39

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

coder/code-server 的其他 Issue

查看 coder/code-server 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。