mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add warning if Content-Type header is missing
This commit is contained in:
parent
2b02cfa00a
commit
87cf7d6408
10
server.ts
10
server.ts
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue