From 212d8042c201ca384795b2b9bea0439580727840 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:51:17 -0400 Subject: [PATCH] Handle clients that include the charset --- functions/_middleware.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/_middleware.ts b/functions/_middleware.ts index 1cd5b26..75042fa 100644 --- a/functions/_middleware.ts +++ b/functions/_middleware.ts @@ -195,7 +195,11 @@ async function setBody(context: RequestContext) { context.request.method === "POST" && !context.request.url.endsWith("/api/infractions/new") ) { - if (context.request.headers.get("content-type") !== "application/json") + if ( + !context.request.headers + .get("content-type") + ?.startsWith("application/json") + ) return new Response('{"error":"Invalid content-type"}', { headers: { "content-type": "application/json",