GamerZero
GamerZero14mo ago

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
}
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
3 Replies
GamerZero
GamerZero14mo ago
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)
Mugetsu
Mugetsu13mo ago
@GamerZero did you find anything related to your issue?
GamerZero
GamerZero13mo ago
Besides what I've already said here, no.