APEX
How to pass context to vanilla client?
I am aware that this is probably an uncommon and unsupported use case (specifically the part about this being a 3rd party client), but I still think it highlights either a feature missing from the vanilla client, or, if the feature does exist, it highlights missing documentation for it
27 replies
How to pass context to vanilla client?
There is a server running NodeJS+tRPC. I am trying to write a different NodeJS package, also using tRPC, for making programmatic API calls to that server. The API server does session tracking using Set-Cookie. The API client, since it is also NodeJS, does not respect the Set-Cookie header (as far as I am aware), so I have to access the header myself to store the cookie in a variable somewhere. My issue is that I cannot figure out how to directly access the request header using @trpc/client.
27 replies
How to pass context to vanilla client?
The solution I'm using as of yesterday is to use
fetch
to call the login API and save the cookie to a variable, then use the headers
function of the object I pass to httpBatchLink
to set that cookie in subsequent requests' headers (using tRPC for subsequent requests).27 replies