Add warning if Content-Type header is missing

This commit is contained in:
Jesse Wierzbinski 2024-04-11 18:19:04 -10:00
parent 2b02cfa00a
commit 87cf7d6408
No known key found for this signature in database

View file

@ -147,6 +147,16 @@ export const createServer = (
return errorResponse("Unauthorized", 401);
}
// Check is Content-Type header is missing in relevant requests
if (["POST", "PUT", "PATCH"].includes(req.method)) {
if (!req.headers.has("Content-Type")) {
return errorResponse(
`Content-Type header is missing but required on method ${req.method}`,
400,
);
}
}
let parsedRequest = {};
try {