CR1M50N
CR1M50N2w ago

How to add req to Context?

I have tried multiple variations of the inner/outer context docs code, but ctx.req and ctx.res are always undefined. https://trpc.io/docs/server/context#inner-and-outer-context. In this related issue, Julius stated that the code shouldn't even work. https://github.com/trpc/trpc/issues/5344. What is the official consensus on this? If it doesn't work then how else does one add the request to context (and why is it in the docs).
GitHub
Issues · trpc/trpc
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - Issues · trpc/trpc
Context | tRPC
Your context holds data that all of your tRPC procedures will have access to, and is a great place to put things like database connections or authentication information.
Solution:
I believe the issue was because I had created a trpc caller without passing the req object.
Jump to solution
1 Reply
Solution
CR1M50N
CR1M50N2w ago
I believe the issue was because I had created a trpc caller without passing the req object.