From 0b725b79472d0b5292e20a83f65ac14440e668bf Mon Sep 17 00:00:00 2001 From: Dmitry Konovenski Date: Thu, 19 Mar 2026 19:08:17 +0000 Subject: [PATCH] Fix local dev server: serve dist/ assets and fix WebSocket port Two issues prevented `npm run build && npm run serve` from working out of the box: 1. The Express server only served static files from `public/` but not from `dist/`, so the built `editor.js` bundle returned 404. 2. `startCollabRuntimeEmbedded` sets `wsUrlBase` to the main HTTP port (e.g. ws://localhost:4000/ws) but `resolveRequestScopedCollabWsBase` did not know the runtime was embedded. Without the COLLAB_EMBEDDED_WS flag, it computed the collab URL as port+1 (4001), causing WebSocket connection refused errors and a perpetual "Connecting" state. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/collab.ts | 6 ++++++ server/index.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/server/collab.ts b/server/collab.ts index 281d6d1f..cbad5587 100644 --- a/server/collab.ts +++ b/server/collab.ts @@ -10406,6 +10406,12 @@ export async function startCollabRuntimeEmbedded(mainHttpPort: number): Promise< }, } as unknown); + // Signal embedded mode so resolveRequestScopedCollabWsBase keeps the + // main HTTP port instead of adding +1 for a standalone collab port. + if (!process.env.COLLAB_EMBEDDED_WS) { + process.env.COLLAB_EMBEDDED_WS = '1'; + } + runtime = { enabled: true, wsUrlBase: wsUrlBase.replace(/\/+$/, ''), diff --git a/server/index.ts b/server/index.ts index 268cc051..1d4d042f 100644 --- a/server/index.ts +++ b/server/index.ts @@ -44,6 +44,7 @@ async function main(): Promise { app.use(express.json({ limit: '10mb' })); app.use(express.static(path.join(__dirname, '..', 'public'))); + app.use(express.static(path.join(__dirname, '..', 'dist'))); app.use((req, res, next) => { const originHeader = req.header('origin');