How can I access body in preHandler on form-data request & application/json request?
biigpongsatorn opened this issue · 1 comments
biigpongsatorn commented
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.x.x
Plugin version
No response
Node.js version
20.3.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.6.1
Description
I was trying to validate the body before sending the request to upstream server. But I don't know how to read the body from the request.
And my proxy should be support application/json and multipart/form-data. So how can I access the body value from both type of requests?
Link to code that reproduces the bug
No response
Expected Behavior
preHandler: async (request) => {
const contentType = request.headers['content-type']
if (contentType === 'application/json') {
// I want to access body data here
} else if (contentType === 'multipart/form-data') {
// I want to access body data here
}
}biigpongsatorn commented
Related to this PR
"fastify-reply-from" is not compatible with "fastify-multipart," so I will close this issue.