How coder/code-server works
code-server runs the VS Code server on a remote machine and serves its browser client over HTTP and WebSockets. The principal workflow is CLI configuration and startup, HTTP/WebSocket routing, authentication, then dispatch to VS Code or optional forwarded services; users interact with the resulting browser IDE. The README emphasizes remote development and consistent environments, while the tree and excerpts show operational capabilities such as login, proxying, updates, health checks, and workspace opening. Some route wiring is only partly excerpted, so unverified links are omitted.
Main entry points: index.ts Route registration · main.ts Server lifecycle · app.ts HTTP app server · vscode.ts VS Code routes
Components 21
Startup and configuration
- CLI configuration
src/node/cli.ts - Process entry
src/node/entry.ts - Server lifecycle
src/node/main.ts - Persistent settings
src/node/settings.ts
HTTP and WebSocket
- HTTP app server
src/node/app.ts - HTTP security helpers
src/node/http.ts - WebSocket dispatch
src/node/wsRouter.ts - Event emitter
src/common/emitter.ts - HTTP primitives
src/common/http.ts
Access and routing
- Route registration
src/node/routes/index.ts - Login and logout
src/node/routes/login.ts - Health checks
src/node/routes/health.ts - Domain forwarding
src/node/routes/domainProxy.ts - Port forwarding
src/node/routes/pathProxy.ts - Update endpoint
src/node/routes/update.ts - Release checker
src/node/update.ts
Editor runtime
- VS Code routes
src/node/routes/vscode.ts - Editor socket
src/node/vscodeSocket.ts - VS Code server
lib/vscode - Browser service worker
src/browser/serviceWorker.ts
Other components
- Browser user
Connections 21
- Browser user → HTTP app server: opens IDE
- Process entry → CLI configuration: parses options
src/node/entry.ts - Process entry → Server lifecycle: starts server
src/node/entry.ts - Server lifecycle → HTTP app server: creates server
src/node/main.ts - Server lifecycle → Route registration: registers routes
src/node/main.ts - HTTP app server → WebSocket dispatch: handles upgrades
src/node/app.ts - WebSocket dispatch → Route registration: dispatches sockets
src/node/routes/index.ts - Route registration → Login and logout: mounts auth
src/node/routes/index.ts - Route registration → Health checks: mounts checks
src/node/routes/index.ts - Route registration → Domain forwarding: mounts proxy
src/node/routes/index.ts - Route registration → Port forwarding: dispatches paths
src/node/routes/index.ts - Route registration → Update endpoint: mounts endpoint
src/node/routes/index.ts - Route registration → VS Code routes: mounts editor
src/node/routes/index.ts - Route registration → HTTP security helpers: uses security
src/node/routes/index.ts - Route registration → Release checker: configures checker
src/node/routes/index.ts - Server lifecycle → Persistent settings: loads settings
- VS Code routes → VS Code server: delegates requests
src/node/routes/vscode.ts - VS Code routes → CLI configuration: builds editor args
src/node/routes/vscode.ts - HTTP app server → Editor socket: creates session service
src/node/app.ts - Browser user → Browser service worker: loads client support
- HTTP security helpers → HTTP primitives: uses status types
src/node/http.ts