Proxy stream-like responses with Middleware
Unanswered
Mrigal carp posted this in #help-forum
Mrigal carpOP
I am using the middleware file as a proxy for all my api calls, main for the purpose of storing the auth token within the cookiesStore. However i have one endpoint on my server returning a stream of data (similar to what chatgpt does) but the result i'm getting using the proxy is i'm getting the hole text once it's done streaming instead of showing up in real time.
I'm basically doing this on the middleware function, where 'url' is the real server url.
Do you know how can i stream to the frontend the response of the api from this proxy? Thank you for all the help.
I'm basically doing this on the middleware function, where 'url' is the real server url.
return NextResponse.rewrite(url, {
headers: requestHeaders,
});Do you know how can i stream to the frontend the response of the api from this proxy? Thank you for all the help.
2 Replies
English Angora
I have no answer for you, however I would just like to bring some atention to this. I am also not able to figure it out how to stream anything from route handler. Now seeing that there are many questions like this, makes me wonder if it really make sense for me to ask the same question yet again.
Asiatic Lion
Same issue when I configure the rewrite rule on the next.config file... still receive the whole text at the end...