Fastify adapter: Custom content-type parser for application/json is breaking normal REST api requests on a fastify server
See original GitHub issueThis works just fine for tRPC endpoints but breaks other REST api endpoints as request.body
is a string where it’s expected to an object. This can be easily reproduced on the official fastify examples by creating a REST POST
endpoint and sending some data inside body.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
ContentTypeParser - Fastify
If you need to support different content types, you can use the addContentTypeParser API. The default JSON and/or plain text parser can be...
Read more >fastify example doesn't allow POST to pages/api handler #9978
Bug report Describe the bug Performing a POST to an API route when using a fastify server wrapper results in 400 Invalid body...
Read more >Fasity Complete Course - learn how to build REST API's
I will show you how you can build a rest Apis using a framework called fastify which is a nodejs framework and it...
Read more >Streaming Files | NestJS - A progressive Node.js framework
To do this with Nest, normally you'd do the following: ... Fastify, by default, can support sending files without needing to call stream.pipe(res)...
Read more >GraphQL Code Libraries, Tools and Services
import RequestParser from "@graphql-box/request-parser"; ... GraphQL server and a hypermedia API supporting modern REST formats (JSON-LD, JSONAPI...): <?php.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes exactly. I think if we can match the fastify-plugin type, we don’t need to encapsulate it and can use it directly. Thanks for the quick fix.
@soulsam480 I found the problem, I am working on a fix…
Reading the docs:
I probably broke the encapsulation system with the use of fastify-plugin, I’m reworking the plugin to allow its use with or without fastify-plugin.