From a1f49f7be3189c083f6d69f6939cd092ed54ff90 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 15 Apr 2024 23:29:42 +0200 Subject: send textual 404 if not accepting text/html --- src/app.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app.ts b/src/app.ts index 53433a9..8d08e0b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -235,6 +235,11 @@ export const server = { } status = 404; const notfound = files.get("/404.html"); + if (!request.headers.get("accept")?.split(",").includes("text/html")) { + return new Response("404 Not Found", { + status, + }); + } if (notfound) { return serveFile(notfound, status, { "content-type": "text/html; charset=utf-8", -- cgit 1.4.1