Skip to content

Fix local dev server: serve dist/ assets and fix WebSocket port#30

Open
konovenski wants to merge 1 commit intoEveryInc:mainfrom
konovenski:fix/local-dev-server-setup
Open

Fix local dev server: serve dist/ assets and fix WebSocket port#30
konovenski wants to merge 1 commit intoEveryInc:mainfrom
konovenski:fix/local-dev-server-setup

Conversation

@konovenski
Copy link
Copy Markdown

Summary

Two issues prevented npm run build && npm run serve from working out of the box for local development:

  • Missing static file serving for dist/: The Express server only served files from public/ but the built editor.js bundle lives in dist/assets/, returning 404 and showing a white screen.
  • WebSocket connecting to wrong port: startCollabRuntimeEmbedded correctly sets wsUrlBase to ws://localhost:4000/ws, but resolveRequestScopedCollabWsBase didn't know the runtime was embedded. Without the COLLAB_EMBEDDED_WS flag, it computed port+1 (4001) for the collab WebSocket URL, causing connection refused errors and a perpetual "Connecting" state.

Changes

  • server/index.ts: Add express.static for the dist/ directory so built assets are served
  • server/collab.ts: Set COLLAB_EMBEDDED_WS=1 in startCollabRuntimeEmbedded so the request-scoped URL resolver uses the correct port

Test plan

  • npm install && npm run build && npm run serve
  • Open POST /documents to create a doc, then navigate to the returned URL
  • Verify editor loads with content visible (no white screen)
  • Verify WebSocket connects on port 4000 (green dot, no console errors)
  • Verify npm run dev (Vite) still works correctly for development

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant