fastify-multer
fastify-multer copied to clipboard
Fastify v5 fails with HTTP 415 FST_ERR_CTP_INVALID_MEDIA_TYPE
When I upgrade from Fastify v4.28 to 5.2, uploads of multipart/form-data failed with a 415 HTTP:
{
"code": "FST_ERR_CTP_INVALID_MEDIA_TYPE",
"name": "FastifyError",
"statusCode": 415,
"message": "Unsupported Media Type: multipart/form-data; boundary=---------------------------33065737953259411260621758869"
}
I found a workaround by replacing the standard :
server.register(multer.contentParser)
with the following:
server.addContentTypeParser('multipart/form-data', function (request, payload, done) {
done(null)
})
I suggest you change the code on lib/content-parser.ts with:
fastify.addContentTypeParser('multipart/form-data', setMultipart)
@fox1t Hope your upgrading