fix: add CORS headers to streaming chat response
Merged
SW
10mo ago+7+7+0123456789-2-2-0123456789
Summary
- Add CORS headers to
createUIMessageStreamResponsecall inhandleChatStream.tsso streaming responses include proper CORS headers - Add
x-api-keytoAccess-Control-Allow-HeadersingetCorsHeaders.tssince the/api/chatendpoint requires API key authentication - Update
handleChatStream.test.tsto expect CORS headers in the streaming response
Problem
Cross-origin requests to /api/chat from client interfaces (e.g., http://localhost:3000 to https://test-recoup-api.vercel.app/api/chat) were being blocked with:
Access to fetch at 'https://test-recoup-api.vercel.app/api/chat' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The OPTIONS handler and error responses already included CORS headers, but the successful streaming response did not.
Test plan
- Verify
/api/chatrequests from cross-origin clients no longer fail with CORS errors - Verify streaming responses include
Access-Control-Allow-Origin: *header - Verify
x-api-keyheader is allowed in preflight requests
š¤ Generated with Claude Code