From 336db032a44072819697b40f32e89e9f3ce3f990 Mon Sep 17 00:00:00 2001 From: metatroncubeswdev Date: Sun, 18 Oct 2026 01:36:42 -0400 Subject: [PATCH] Return JSON, not plain text, from the Autumn route's 404 autumn-js's client hooks call response.json() on every response regardless of status. The plain-text "Not found" body from the previous commit's guard made that throw a SyntaxError client-side ("Unexpected token 'N'...") in hosted mode once Autumn-dependent UI actually mounted and called it. Co-Authored-By: Claude Sonnet 5 --- src/routes/api/autumn/$.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/routes/api/autumn/$.ts b/src/routes/api/autumn/$.ts index 60adbc6..fb95f52 100644 --- a/src/routes/api/autumn/$.ts +++ b/src/routes/api/autumn/$.ts @@ -60,9 +60,13 @@ async function handleAutumnRequest(request: Request) { // loadHandler(), avoids autumn-js throwing "secret key not found" deep // inside the handler once a client request reaches it. if (!isHostedAuthMode(env.AUTH_MODE) || !env.AUTUMN_SECRET_KEY?.trim()) { - return new Response("Not found", { - status: 404, - }); + // JSON, not a plain-text body: the client-side autumn-js hooks call + // response.json() on every response regardless of status, and a + // non-JSON body throws a SyntaxError there instead of handling the 404. + return Response.json( + { message: "Not found", code: "not_found" }, + { status: 404 }, + ); } let context;