denik1981
denik198113mo ago

When using createServerSideHelpers can the context be typed as GetServerSidePropsContext?

I assume the reason we should recreate the context when using createServerSideHelpers is because the req, res we get from GetServerSidePropsContext are not typed the same as the ones we get from NextApiRequest and NextApiResponse. Fair enough. but can I create create my context based on the ctx we get from GetServerSidePropsContext? If that the case is it a good approach to extend the InnerContext from the union of the both Partial contexts, and by "both" I mean the context we are expected to get and work with when calling our routers from the next API handler and from getServerSideProps? Sorry if my question is not very clear and probably the answer won't be needed by me because I'm trying to not use getServerSideProps at all but still I would like to master my understanding of how TRPC serverSideHelpers are doing this in case I need them in the future. The goal here will be to keep procedures that depend in certain values obtain from req or res being able to work dispite the source of the caller. So I would expect to regenerate the context for my instance of serverSideHelpers properly to make the request pass and being processed without troubles. Thanks!
0 Replies
No replies yetBe the first to reply to this messageJoin