Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastify v5 fails with HTTP 415 FST_ERR_CTP_INVALID_MEDIA_TYPE #35

Open
nioc opened this issue Dec 29, 2024 · 0 comments · May be fixed by #36
Open

Fastify v5 fails with HTTP 415 FST_ERR_CTP_INVALID_MEDIA_TYPE #35

nioc opened this issue Dec 29, 2024 · 0 comments · May be fixed by #36

Comments

@nioc
Copy link

nioc commented Dec 29, 2024

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)
nioc added a commit to nioc/fastify-multer that referenced this issue Dec 29, 2024
@nioc nioc linked a pull request Dec 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant