clear cookie onError

TTkDodo 🔮11/15/2022
I'd like to clear a cookie (in nextjs) when a 403 error happens. I've been looking at the global error handling: https://trpc.io/docs/error-handling#handling-errors 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 ?
AKAlex / KATT 🐱11/15/2022
Middlewares are more flexible, have you tried that?
UUUnknown User11/15/2022
Message Not Public
Sign In & Join Server To View
TTkDodo 🔮11/16/2022
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()
AKAlex / KATT 🐱11/16/2022
The result never throws but returns an Either style thing Clearly we need to document it better haha

Looking for more? Join the community!

Recommended Posts
Request context from getServerSidePropsThe docs of tRPC context https://trpc.io/docs/v10/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 https://trpc.io/docs/v10/error-handling 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