about summary refs log tree commit diff stats
path: root/src/app.ts
diff options
context:
space:
mode:
authorAlan Pearce2024-04-15 23:29:42 +0200
committerAlan Pearce2024-04-15 23:29:42 +0200
commita1f49f7be3189c083f6d69f6939cd092ed54ff90 (patch)
tree3fa26f852421155f413f9d514555e79a03919058 /src/app.ts
parentd7ac66da3ccffb266caed2ebce574a4ab5737e79 (diff)
downloadwebsite-a1f49f7be3189c083f6d69f6939cd092ed54ff90.tar.lz
website-a1f49f7be3189c083f6d69f6939cd092ed54ff90.tar.zst
website-a1f49f7be3189c083f6d69f6939cd092ed54ff90.zip
send textual 404 if not accepting text/html
Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts5
1 files changed, 5 insertions, 0 deletions
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",