From e938d3395abbc6dbbf4ad4026773b1307d94126e Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 2 Mar 2026 11:05:34 -0500 Subject: [PATCH] Throw Response from apiJson so API 404s render as 404 pages apiJson was throwing a plain Error on non-ok responses, which React Router always treated as a 500. Now throws a Response with the actual status code so API 404s surface as proper 404 error pages. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/arc-web/app/api-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/arc-web/app/api-client.ts b/apps/arc-web/app/api-client.ts index 92a469f4a..30d920b2b 100644 --- a/apps/arc-web/app/api-client.ts +++ b/apps/arc-web/app/api-client.ts @@ -51,6 +51,6 @@ export async function apiFetch( */ export async function apiJson(path: string, init?: RequestInit): Promise { const res = await apiFetch(path, init); - if (!res.ok) throw new Error(`API ${res.status}: ${await res.text()}`); + if (!res.ok) throw new Response(await res.text(), { status: res.status }); return res.json() as Promise; }