`nodeHTTPRequestHandler` stripping out headers, body, and middlewares with Fastify
See original GitHub issueHello, we’ve been trying out TRPC on professional projects with Fastify.
We noticed the requestHandler
or nodeHTTPRequestHandler
is using reply.raw
skipping all middleware-defined headers and functionalities including CORS making it unfortunately unusable for production.
according to https://www.fastify.io/docs/latest/Reference/Reply/#raw
.raw
This is the http.ServerResponse from Node core. Whilst you are using the Fastify Reply object, the use of Reply.raw functions is at your own risk as you are skipping all the Fastify logic of handling the HTTP response. e.g.:
as shown on #524
await nodeHTTPRequestHandler({
req: req.raw,
res: reply.raw, <----- HERE
router,
createContext,
path: (req.params as any).path,
});
how can we help ?
thank you
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Error: Can't set headers after they are sent to the client
When the server gets a request, it iterates over the stack, calling the (request, response, next) method. The problem is, if in one...
Read more >Build a CRUD API with Fastify - DEV Community
Hello everyone, in this article we are going to build a NodeJS CRUD API with Fastify. Fastify is a NodeJS framework for building...
Read more >Proposal: remove request/reply and expose just context #169
Because the actual Fastify request object does not contain the headers of the request. In this way we can also fix the tricky...
Read more >How to Migrate Your App from Express to Fastify - SitePoint
This middleware function is built in to Express. It handles parsing JSON request bodies. cors. This middleware helps us add CORS headers to...
Read more >Forget Express.js — opt for these alternatives instead
If you're working on a new project written in Node that acts as a web server, don't default to the familiar Express.js.
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
I see. It seems to me like we should provide a lower level primitive for adapters, where the consumer control the flow of the output rather than tRPC doing
res
directly.I’ll have a look at this in the next few weeks, for now, shim
res
as you’re doing. Great that you found a workaround.This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.