Repository navigation
frontend: 5 API calls omit the /api prefix (331 failed retries observed) — nginx SPA fallback masks them as 405/200-HTML instead of 404 #12317
Description
Summary
Five API calls in the shipped ChatInterface bundle omit the /api prefix. Each has a documented, correct /api/... counterpart in the generated OpenAPI types in the same repo. Because nginx falls back to the SPA for unmatched paths, these never produce a clean 404 — they return 405 on POST or, worse, 200 text/html on GET.
Observed 331 failed requests for the activity-batch call in a single real user session.
The mismatched calls
From dist/assets/ChatInterface-B6-PeAmP.js (current build, 2026-07-24):
| Shipped call | Correct path (per openapi.json) |
Observed |
|---|---|---|
POST /chat/sessions/{id}/activities/batch |
/api/chat/sessions/{id}/activities/batch |
405 (×331) |
POST /chat/sessions/{id}/activities |
/api/chat/sessions/{id}/activities |
405 |
POST /chat/summarize |
/api/chat/summarize |
405 |
GET /image-generation/providers |
/api/image-generation/providers |
200 + HTML |
POST /image-generation/generate |
/api/image-generation/generate |
405 |
The same bundle also contains correctly-prefixed /api/... calls, so this is inconsistency within one file, not a client-wide convention.
Source of the largest offender — src/composables/useSessionActivityLogger.ts:450:
await apiClient.post<unknown>(`/chat/sessions/${sessionId}/activities/batch`, {while the generated contract in the same repo says otherwise:
src/types/generated/api.ts:1017: "/api/chat/sessions/{session_id}/activities/batch": {
The SPA fallback masks it — this is the real problem
$ curl -sk -o /dev/null -w '%{http_code}\n' https://<host>/api/image-generation/models
404 # honest
$ curl -sk https://<host>/image-generation/models -D- -o /dev/null | grep -i content-type
content-type: text/html # SPA index.html
$ curl -sk -o /dev/null -w '%{http_code}\n' https://<host>/image-generation/models
200 # <-- "success"So an un-prefixed GET returns HTTP 200 with <!DOCTYPE html>, and the frontend then tries to parse an HTML page as JSON. An un-prefixed POST returns nginx's 405 because it will not POST to a static file.
Neither failure mode names the actual problem, which is why five wrong paths shipped: there is no configuration in which a missing /api prefix produces a diagnosable error.
Impact
- Session activity telemetry is silently lost — the logger retries in a loop (331 attempts observed) and never succeeds.
- Chat summarization and image generation are wired to dead paths.
- Any future prefix mistake will be equally invisible.
Recommendation
- Fix the five call sites to match the generated contract.
- Stop the SPA fallback from swallowing API paths — add an nginx guard so anything under a known API namespace 404s as JSON instead of serving
index.html:or, better, have the SPA fallback apply only to paths that do not look like API calls.location ~ ^/(chat|image-generation|knowledge_base|llc|transcriber)/ { return 404; # never SPA-fallback a bare API namespace }
- Generate the client from
openapi.json(the types are already generated — the calls are not), or add a lint rule asserting everyapiClient.<verb>path exists as a key insrc/types/generated/api.ts. That check would have caught all five mechanically. - Have
apiClientreject relative paths that do not start with/api, failing loudly in development.
Environment
nginx/1.18.0, install.sh deploy at /opt/autobot, bundle ChatInterface-B6-PeAmP.js built 2026-07-24 15:41. Deployed tree matches origin/Dev_new_gui.
Activity
test(vnc): update assertions to /api/vnc paths after prefix fix (#12317)
fix(frontend): add missing /api prefix to un-prefixed API calls (#12317…
mrveiss commentedon Jul 24, 2026
Delivered in PR #12387 (merged to Dev_new_gui, adversarial code-review APPROVE). Added the missing
/apiprefix to 26 frontend call-sites (the 5 reported + 16 more of the identical class: vnc, video-generation, devices, memory/privacy, knowledge). Review verified every old bare path was genuinely broken (not backend-mounted, not dev-proxied, not SLM) and every corrected/api/...path hits a real route with matching method — no working call broken, no double-prefix. Updated useVncControls spec assertions to match.