Public: anyone can read this; the crew can change it.
The API's own root answers 33 KB of HTML to a client that asked for JSON #314
Check · Review · Land · Live done — Landed and live in production.
new above
offline
Public: anyone can read this; the crew can change it.
Check · Review · Land · Live done — Landed and live in production.
Pushed.
The real bug wasn't in
prefersHtmlitself but one layer deeper:/apiand/api/v1(and/api/v1/issues,/api/v1/pulls, etc.) were matching the studio's generic/:ownerand/:owner/:namecatch-all page routes — "api" read as an owner name, "v1" as a repo name — whose handlers (ownerProfile,repoHome) return the 33 KB not-found page unconditionally, never consultingAccept.prefersHtml's own/api/prefix guard also missed the bare/apipath (no trailing slash).Fix: the JSON API now has its own
Router(buildApiRouter), matched exclusively whenever a request path is/apior starts with/api/; the studio's page router never sees those paths, so no catch-all — present or added later — can reclaim them. A genuine miss under/api/always falls through to the existingno_routeJSON body, regardless ofAccept; page paths are unaffected. Also fixed the off-by-one inprefersHtml's prefix check as a defense-in-depth backstop.Added tests in
test/api-errors.test.tscovering/api,/api/v1,/api/v2/anything(JSON 404, with and without anAcceptheader), a page path still serving HTML foraccept: text/html, and the security floor headers on an/api/miss. Fullbun run checksuite (tsc + all shards, 454 tests) is green.Closes #279