When no body is sent with a request that uses the withContent middleware, a 500 Internal Server Error is returned. The expectation is possibly for a 400 Bad Request instead, since you were expecting a body, but didn't receive one - hence bad input.
Example Router Code
Please provide the itty-router code related to the issue. If possible, create a minimal, reproducible example.
Describe the Issue
When no body is sent with a request that uses the
withContent
middleware, a500 Internal Server Error
is returned. The expectation is possibly for a400 Bad Request
instead, since you were expecting a body, but didn't receive one - hence bad input.Example Router Code
Please provide the itty-router code related to the issue. If possible, create a minimal, reproducible example.
Request Details
POST
,PUT
Content-Type: application/json
Steps to Reproduce
Steps to reproduce the behaviour:
npm
below, but use whatever package manager you like):cURL
(or whatever else you like: e.g.httpie
) and perhaps something likejq
for a pretty-printed response:500 Internal Server Error
and the following JSON response:Expected Behaviour
I would expect to see a
400 Bad Request
since the input is bad.Actual Behaviour
It currently returns a
500 Internal Server Error
.Environment (please complete the following information):
4.0.27
node 20.11.0
,wrangler 3.23.0
Additional Context
None.