Set server response headers from TRPC standalone adapter
Hi
I am trying to implement my own authentication in Trpc. For this I need to create a session on the backend and return appropriate headers like set cookie for
Could find anything here or in the docs. Thank you 🙏
session-token
and csrf-token
.
How can I set these headers from within a mutation when using the standalone adapter.Could find anything here or in the docs. Thank you 🙏
3 Replies
Pass through the req/res objs from createContext and set it in the mutation like you'd do without trpc
Thanks for the idea, managed to do it as follows:
server initialization:
mutation definition:
Not the full code due to character limit, but should suffice if you are looking to do the same :)!
This is great, thank you. What's the
new Cookie()
library you're using? It looks nice