peterp
peterp3y ago

Response headers

Is it possible to modify the response headers from server to client?
10 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
peterp
peterpOP3y ago
🤔 I can see how I have access to req/ response in the context, but does the client have access to those things? As an example:
export async function createContext(
opts?: trpcExpress.CreateExpressContextOptions
) {
opts.res.setHeader('x', 'dog')
}
export async function createContext(
opts?: trpcExpress.CreateExpressContextOptions
) {
opts.res.setHeader('x', 'dog')
}
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
peterp
peterpOP3y ago
I'm building a CLI and need to push information down to the client that isn't part of the query or mutation. I need it in each response, regardless of the context of the request.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
peterp
peterpOP3y ago
👀 aaah, cool I'm not using batching, but maybe I can just wrap fetch or create a custom httpLink I'll play around with modifying the fetch implementation passed to "createTRPCClient" Thanks! I'll report back Btw SpaceDrive looks dope af
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
peterp
peterpOP3y ago
I can imagine! I see we share investors ;P I guess everyone does
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
peterp
peterpOP3y ago
Abstracting the fetch property in createTRPCClient worked like a charm. Thanks for the help!