How to add req to Context?
I have tried multiple variations of the inner/outer context docs code, but
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).
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
Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - Issues ยท trpc/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.