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

Open
#7,976 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

The payload names no code-server files or tests. Start by tracing browser-context handling of outbound localhost WebSockets and the built-in proxy layer, then examine how the injected aspnetcore-browser-refresh.js uses ephemeral ws/wss ports. Done should be a pure-browser dotnet watch workflow where Hot Reload connects through code-server without localhost failures.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
79.4k
Forks
6.9k
Avg merge
2d 13h
Merged PRs (30d)
39

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/code-server

All issues in coder/code-server

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.