Handle clients that include the charset

This commit is contained in:
regalijan 2023-10-19 16:51:17 -04:00
parent 161862712c
commit 212d8042c2
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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",