Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle clients that include the charset
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 1618627 commit 212d804
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions/_middleware.ts
Expand Up @@ -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",
Expand Down

0 comments on commit 212d804

Please sign in to comment.