How cdr/code-server works
code-server runs VS Code on a remote machine and serves its browser-based interface to users. The main workflow starts with command-line configuration, creates an HTTP/WebSocket server, registers routes, and delegates editor requests to the bundled VS Code server. Separate branches handle authentication, proxying, health and update endpoints, and persistent settings. The source index and excerpts establish several internal calls; README statements support the product-level remote-editor workflow. Some route internals and integrations were not sampled, so uncertain connections are omitted.
Main entry points: index.ts Route Registration · app.ts HTTP Server · main.ts Runtime Startup · entry.ts Process Entry
Components 21
Startup and Configuration
- CLI Configuration
src/node/cli.ts - Process Entry
src/node/entry.ts - Runtime Startup
src/node/main.ts
HTTP and Access
- HTTP Server
src/node/app.ts - Route Registration
src/node/routes/index.ts - Authentication
src/node/routes/login.ts - Domain Proxy
src/node/routes/domainProxy.ts - Port Path Proxy
src/node/routes/pathProxy.ts - Proxy Utilities
src/node/proxy.ts
Editor and Sessions
- VS Code Web Server
src/node/routes/vscode.ts - Editor Session Manager
src/node/vscodeSocket.ts - WebSocket Routing
src/node/wsRouter.ts - Browser Resources
src/browser
Runtime Services
- Persistent Settings
src/node/settings.ts - Release Update Check
src/node/update.ts - Health Endpoint
src/node/routes/health.ts - Heartbeat Monitor
src/node/heart.ts
Other components
- Browser User
- Server Operator
- GitHub Releases
- Remote Machine
Connections 24
- Server Operator → Process Entry: starts process
- Process Entry → CLI Configuration: parses options
src/node/entry.ts - Process Entry → Runtime Startup: starts runtime
src/node/entry.ts - Runtime Startup → CLI Configuration: converts editor args
src/node/main.ts - Runtime Startup → HTTP Server: creates server
src/node/main.ts - Runtime Startup → Route Registration: registers routes
src/node/main.ts - HTTP Server → WebSocket Routing: handles upgrades
src/node/app.ts - HTTP Server → Editor Session Manager: creates session server
src/node/app.ts - Route Registration → Authentication: registers login
src/node/routes/index.ts - Route Registration → VS Code Web Server: registers editor routes
src/node/routes/index.ts - Route Registration → Domain Proxy: mounts proxy routes
src/node/routes/index.ts - Route Registration → Port Path Proxy: dispatches port paths
src/node/routes/index.ts - Route Registration → Release Update Check: mounts update endpoint
src/node/routes/index.ts - Route Registration → Persistent Settings: creates settings provider
src/node/routes/index.ts - Route Registration → Heartbeat Monitor: creates monitor
src/node/routes/index.ts - Route Registration → Health Endpoint: registers health endpoint
src/node/routes/index.ts - VS Code Web Server → CLI Configuration: builds editor arguments
src/node/routes/vscode.ts - VS Code Web Server → WebSocket Routing: declares WebSocket routes
src/node/routes/vscode.ts - Domain Proxy → Proxy Utilities: uses proxy helpers
src/node/routes/domainProxy.ts - Port Path Proxy → Proxy Utilities: uses proxy helpers
src/node/routes/pathProxy.ts - Browser User → HTTP Server: connects remotely
- Browser User → Browser Resources: uses browser interface
- HTTP Server → Remote Machine: serves remote VS Code
- Release Update Check → GitHub Releases: checks releases