clear cookie onError

I'd like to clear a cookie (in nextjs) when a 403 error happens. I've been looking at the global error handling: and this looks like the right place, except that I don't have access to the response , which would be needed to clear a cookie. Is there a better place to do this, or is there a reason there is no access to the res ?
Error Handling | tRPC
Whenever an error occurs in a procedure, tRPC responds to the client with an object that includes an "error" property. This property contains all the information that you need to handle the error in the client.
Alex / KATT 🐱520d ago
Middlewares are more flexible, have you tried that?
Unknown User520d ago
TkDodo 🔮519d ago
I added a function to remove the cookies into the ctx - that works. Haven't looked at middlewares - the logging example shows how I can await the result and then act on it. I'll try if this also works for errors. Not sure if I'd have to try/catch the const result = await next()
Alex / KATT 🐱519d ago
The result never throws but returns an Either style thing Clearly we need to document it better haha
More Posts
Request context from getServerSidePropsThe docs of tRPC context ``` export async function createContext(oAuth with passport.jsEvening all, Has anyone successfully setup trpc with passport.js for auth?Object keeps getting overwrittenI feel like i'm missing something fundamental here. when I add a new entry into object ``b`` it resAccessToken for API callsWhat would be the best approach to pass the AccessToken from NextAuth Session to the Http Client whiRequest or Response Specification Definition DocumentI am developing a backend service using trpc, but I need to dispatch trpc in another programming lanabortOnUnmount config errorI'm encountering an error when passing abortOnUnmount saying that it does not exist as a possible pazustand + trpc (basic data fetching)im trying to use zustand with trpc, but having trouble setting some data to global state. What am i TypeError Cannot destructure property 'abortOnUnmount' of 'useContext(...)' as it is null.Zero Clue what is error mean exactly....First time learning trpc really good tool. help with setting cookies on front end.Hello how do you use tRPC to make a cookie and send it to the front end. or is there any other methoHow do we add settings in each query like before?Since the new update, bee super confused. I used to do this, and can't recreate it now. ``` const Handling error globallyAccording to the docs on errors I should get such error objecant access trpc endpoints via the browseri'm converting some express endpoints to trpc, and I cant figure out how to access my endpoints via