free-coding-models icon indicating copy to clipboard operation
free-coding-models copied to clipboard

Docker mode: 4 web dashboard API endpoints return 404

Open stgreenb opened this issue 5 months ago • 2 comments

Bug description

When running FCM in Docker mode (router daemon on port 19280), the web dashboard loads but 4 API endpoints used by the frontend return 404. These endpoints work in local dev mode (where web/server.js runs alongside the daemon), but the daemon itself (router-daemon.js) doesn't serve them.

Affected endpoints

Endpoint Method What the frontend uses it for
/api/router/status GET Router dashboard polling (RouterView.jsx, useRouterDashboard.js)
/api/router/stats GET Router dashboard stats (RouterView.jsx, useRouterDashboard.js)
/api/router/sets GET Router dashboard set list (RouterView.jsx, useRouterDashboard.js)
/api/changelog GET Changelog modal (useChangelog.js)

Root cause

The web dashboard (web/server.js) defines these routes with the /api/router/ prefix and /api/changelog. The router daemon (src/core/router-daemon.js) defines equivalent routes without the prefix:

  • /api/router/status → daemon has /stats (line 2476)
  • /api/router/stats → daemon has /stats (line 2476)
  • /api/router/sets → daemon has /sets (line 2173)
  • /api/changelog → not implemented in daemon at all

In local dev mode, web/server.js proxies these requests to the daemon, so they work. In Docker mode, only the daemon runs — so the prefixed paths return 404.

Steps to reproduce

  1. Run docker run -p 19280:19280 ghcr.io/vava-nessa/free-coding-models:latest
  2. Open http://localhost:19280/
  3. Open browser DevTools Network tab
  4. Observe 404 responses for:
    • GET /api/router/status
    • GET /api/router/stats
    • GET /api/router/sets
    • GET /api/changelog

Expected behavior

All 4 endpoints should return valid JSON responses, matching the local dev experience.

Actual behavior

All 4 endpoints return 404 Not found.

Impact

  • Router Dashboard tab in the web UI is non-functional (status, stats, sets all 404)
  • Changelog modal shows an error
  • The rest of the dashboard (model list, settings, playground) works fine

Suggested fix

Add route aliases in router-daemon.js that map the /api/router/ prefixed paths to the existing handlers, or add the /api/changelog endpoint. This keeps the daemon self-contained for Docker mode while preserving the existing route structure.

stgreenb avatar Jun 10 '26 17:06 stgreenb

Thanks for the detailed bug report @stgreenb — great root-cause analysis, it made the fix straightforward.

Fix

The root cause is exactly as you described: the daemon (router-daemon.js) only serves its canonical routes (/health, /stats, /sets) while the React frontend expects the /api/router/* prefixed paths that web/server.js defines. In Docker mode, only the daemon runs → 404s.

The daemon now exposes alias routes that map the frontend's expected paths directly:

Frontend route Daemon handler
GET /api/router/status statusPayload()
GET /api/router/stats statsPayload()
GET /api/router/sets handleSetsRequest() (path rewritten)
GET /api/router/tokens tokenTracker.summary()
GET /api/router/quick-setup Self-hosted daemon info
GET /api/changelog loadChangelog() (new endpoint)
POST /api/router/start { alreadyRunning: true }
POST /api/router/stop Triggers shutdown()
POST /api/router/probe-mode Existing handler
/api/router/sets/:name/* Rewritten → /sets/:name/*

All mutating aliases are guarded with the same isSameOriginOrLocal origin check used by the rest of the daemon, so cross-origin CSRF on localhost is blocked.

No frontend changes needed — the fix is purely server-side. Will ship in the next release.

vava-nessa avatar Jun 11 '26 11:06 vava-nessa

✅ Already fixed in v0.5.28 (commit 2c07925). All 4 endpoints are now served by the daemon in Docker mode: /api/router/status (L2634), /api/router/stats (L2638), /api/router/sets (L2695), /api/changelog (L2691). No dev proxy needed. Verify your version with free-coding-models --version.

vava-nessa avatar Jul 25 '26 20:07 vava-nessa