Skip to content

Commit

Permalink
Recommended fix for CORs immutable headers issue
Browse files Browse the repository at this point in the history
Fixes kwhitley#261 by creating a new response with mutable headers and avoiding duplicating the body. The correct fix for what kwhitley@74f63ab#diff-a1624121bc1fee18f8a5c2b2f907f01ba9c56a50068007e4c5da2911e91ea6df was trying to achieve.
  • Loading branch information
jacwright authored Jan 16, 2025
1 parent 3a81994 commit 18ca2e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const cors = (options: CorsOptions = {}) => {
|| response.status == 101
) return response

return appendHeadersAndReturn(response.clone(), {
return appendHeadersAndReturn(new Response(response.body, response), {
'access-control-allow-origin': getAccessControlOrigin(request),
'access-control-allow-credentials': credentials,
})
Expand Down

0 comments on commit 18ca2e9

Please sign in to comment.