T
tRPC

Cannot set headers in procedures with fetch adapter

Cannot set headers in procedures with fetch adapter

GGamerZero9/12/2023
Am i right that with such a setup in nextjs app router route handler:
const handler = async (request: NextRequest) => {
const response = await fetchRequestHandler({... request ...})
return response
}
const handler = async (request: NextRequest) => {
const response = await fetchRequestHandler({... request ...})
return response
}
It is currently impossible to set headers inside a procedure, cause fetchRequestHandler just starts to stream proceddure response as body and resolves immedieately, not waiting for it to finish? That's the behaviour that im observing right now: 1) setting header in procedure and logging 2) logging after await fetchRequestHandler() 3) first log is shown after the second one And headers are not set cause body already started streaming i think
GGamerZero9/13/2023
If my assumptions are correct, what can i do about it? I've tried implementing the adapter synchronously, without streaming using resolveHTTPResponse directly. But unfortunately getting JSON.parse() errors on client (non-whitespace character after json at column X)
MMugetsu10/16/2023
@GamerZero did you find anything related to your issue?
GGamerZero10/16/2023
Besides what I've already said here, no.

Looking for more? Join the community!

T
tRPC

Cannot set headers in procedures with fetch adapter

Join Server
Recommended Posts
Does anybody now how to fix cors policy error?I am facing this error: Access to fetch at 'http://localhost:3002/trpc/getBotTag?batch=1&input=%7B%7how to handle error from Zod in trpc?I would like to return error instead throwing it away so i could show user nice feedback i found htt404 TRPCError: no query procedure on pathHi, this is my entire standalone tRPC server:```ts import { initTRPC } from "@trpc/server"; import {Call multiple TRPC endpoints from onSuccess()?I would like to create an API chain for analysing a geographic area where one successful API call caHow to set sizeLimit > 1MB (to solve 413 error)?Hi all, I am trying out the T3 stack where I want to send area polygons given by the user to my NexHow to manage server to server communicationWould managing headers this way work in nextjs as server to server communication? or does next managReplacing the dot notation in URLs with forward slash `/` ?is there a way to replace the dot separation with a forward slash instead ? so instead of `/api/tWhich one method should I use for creating trpc for server componetns in Nextjs 13 App dirHi which one I should use experimental_createTRPCNextAppDirServer or createTRPCProxyClient when it cCan someone explain to me the use of tRPC in server components?I can really see the need for tRPC in client components but can someone explain to me how you would Error-Boundary and TRPCIs there a nice way to catch errors from TRPC at a global level and bubble them into a simple alert Type errors in lambda integrationI really don't know where to start with this error.... I'm going to be integrating tRPC into a lambHybrid application with offline and online mode setup with tRPCHi, I was wondering if I could setup tRPC in way that one http link is using local API (for offline