warflash
warflash
Explore posts from servers
TtRPC
Created by warflash on 6/1/2024 in #❓-help
How to prevent leaking error messages to client?
No description
4 replies
TtRPC
Created by warflash on 4/8/2024 in #❓-help
Middleware context changes aren't applied to `responseMeta(opts)` options
In our middleware I extend the ctx like this:
const public = t.middleware(async ({ next, ctx }) => {
return next({
ctx: {
enableCache: true,
},
})
})
const public = t.middleware(async ({ next, ctx }) => {
return next({
ctx: {
enableCache: true,
},
})
})
and then in the api handler where I'd like to add cache headers in the reponseMeta function I try accessing ctx. However it hasn't been modified there and returns an empty object. Accessing ctx in my router procedure itself properly returns the right context.
export default trpcNext.createNextApiHandler({
router: appRouter,
createContext,
responseMeta(opts) {
console.log(opts);
return {};
},
});
export default trpcNext.createNextApiHandler({
router: appRouter,
createContext,
responseMeta(opts) {
console.log(opts);
return {};
},
});
Any idea on how I can get this to work? Thank you!
2 replies