From cf21a56d7ac3cbac43f792658363c6595edc5613 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 4 May 2025 14:45:35 -0400 Subject: [PATCH] Add API endpoint to return request headers as a gzipped JSON response --- index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.ts b/index.ts index d2d9b51..f99d211 100644 --- a/index.ts +++ b/index.ts @@ -155,6 +155,15 @@ const webserver = serve({ const request = new Request(req); request.headers.delete('cookie'); return await fetch("https://plausible.creations.works/api/event", request); + }, + "/api/headers": async (req) => { + return new Response(gzipSync(JSON.stringify({ headers: req.headers })), { + headers: { + "Content-Type": "application/json", + "Content-Encoding": "gzip", + "Cache-Control": "no-cache", + } + }) } }, websocket: {