Request context inside middleware?

NNEO10/13/2022
Hi,

Is it possible to get the request context inside a middleware somehow?
I'm trying to migrate a Express Based API

const t = initTRPC.context<Context>().create();

const useAuthentication =  t.middleware(({ next, ctx }) => {
   const token = ctx.req.headers['authorization']
})
Ccloudfox10/13/2022
the way you're doing it is correct
NNEO10/13/2022
@sachin I get a type error though
NNEO10/13/2022
NNEO10/13/2022
Fixed that by making context property optional but getting undefined error on the req.headers line
NNEO10/13/2022
NNEO10/13/2022
Also fixed by returning req, res in HTTP context
NNEO10/13/2022
Closing the post