GamerZeroG
tRPC3y ago
5 replies
GamerZero

Cannot set headers in procedures with fetch adapter

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
}

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
Was this page helpful?