#vercel/ai - useChat(onResponse) failing to read response headers
1 messages · Page 1 of 1 (latest)
I'm sorry, but I don't have enough information to provide a confident answer to your question. The knowledge sources provided do not contain specific information about the useChat function from vercel/ai or how to handle its onResponse callback.
However, there are some related issues discussed in the knowledge sources that might be relevant. For example, there's an open issue on GitHub about response headers not being accessible on API routes in Vercel [source] (https://github.com/vercel/next.js/issues/40275). The issue describes a similar problem where headers set in middleware are not accessible in the API routes when the app is deployed to Vercel, even though they work fine locally.
It's also worth noting that one of the comments in this issue mentions that the problem seems to only affect the edge runtime, and switching to the nodejs runtime resolved the issue [source] (https://github.com/vercel/next.js/issues/45371).