Hello!
I’ve encountered an issue with uploading files using a Redwood Function… Currently, I’m calling a Redwood-generated function using an axios “post” request that sends an instance of FormData that contains a file, and includes this header: 'Content-Type': 'multipart/form-data'
This causes the following error:
{
"statusCode": 400,
"code": "FST_ERR_CTP_INVALID_CONTENT_LENGTH",
"error": "Bad Request",
"message": "Request body size did not match Content-Length"
}
…some research indicates this is how Fastify works under the hood, and can be dealt with by using an appropriate Fastify plugin to parse the 'multipart/form-data'
content type.
The Redwood docs even mention this here, but, the server.config.js
file I see seems to differ quite a bit from the example in the docs (I’m on Redwood 7.0.2).
Does anyone know how to fix this, either via an appropriate Fastify plugin, or perhaps via a different approach?
Thanks!