Uh oh!
There was an error while loading. Please reload this page.
fix: add CORS headers to streaming chat response - #138
Conversation
- Add CORS headers to createUIMessageStreamResponse call in handleChatStream - Add x-api-key to Access-Control-Allow-Headers in getCorsHeaders - Update handleChatStream test to expect CORS headers Fixes cross-origin requests to /api/chat endpoint being blocked. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
Summary
createUIMessageStreamResponsecall inhandleChatStream.tsso streaming responses include proper CORS headersx-api-keytoAccess-Control-Allow-HeadersingetCorsHeaders.tssince the/api/chatendpoint requires API key authenticationhandleChatStream.test.tsto expect CORS headers in the streaming responseProblem
Cross-origin requests to
/api/chatfrom client interfaces (e.g.,http://localhost:3000tohttps://test-recoup-api.vercel.app/api/chat) were being blocked with:The
OPTIONShandler and error responses already included CORS headers, but the successful streaming response did not.Test plan
/api/chatrequests from cross-origin clients no longer fail with CORS errorsAccess-Control-Allow-Origin: *headerx-api-keyheader is allowed in preflight requests🤖 Generated with Claude Code