You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
koa-body sets ctx.request.body = {} even when no body is parsed (index.ts#L109). This prevents other middleware from correctly determining whether a request body exists.
For example, koa-bodyparser (index.js#L64) only parses the request if ctx.request.body is undefined. Since koa-body sets it to {}, koa-bodyparser skips parsing, causing unexpected behavior.
Expected Behavior
If no body is parsed, ctx.request.body should remain undefined so that downstream middleware (including koa-bodyparser) can handle it appropriately.
Steps to Reproduce
Use koa-body in a Koa app.
Send a request without a body (e.g., a GET request or an empty POST request).
Observe that ctx.request.body is {} instead of undefined, which may prevent other middleware from handling the request properly.
Possible Fix
Avoid setting "{}" when the request body is not parsed.
The text was updated successfully, but these errors were encountered:
koa-body/src/index.ts
Line 109 in c93a643
Description
koa-body sets ctx.request.body = {} even when no body is parsed (index.ts#L109). This prevents other middleware from correctly determining whether a request body exists.
For example, koa-bodyparser (index.js#L64) only parses the request if ctx.request.body is undefined. Since koa-body sets it to {}, koa-bodyparser skips parsing, causing unexpected behavior.
Expected Behavior
If no body is parsed, ctx.request.body should remain undefined so that downstream middleware (including koa-bodyparser) can handle it appropriately.
Steps to Reproduce
Use koa-body in a Koa app.
Send a request without a body (e.g., a GET request or an empty POST request).
Observe that ctx.request.body is {} instead of undefined, which may prevent other middleware from handling the request properly.
Possible Fix
Avoid setting "{}" when the request body is not parsed.
The text was updated successfully, but these errors were encountered: