Skip to content

Commit

Permalink
fix: corsify issue "can't modify immutable headers"
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasvienot committed Jun 27, 2024
1 parent f4d79f0 commit c1721e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ export const cors = (options: CorsOptions = {}) => {
|| response.status == 101
) return response

return appendHeadersAndReturn(response.clone(), {
const responseCopy = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: response.headers,
})

return appendHeadersAndReturn(responseCopy, {
'access-control-allow-origin': getAccessControlOrigin(request),
'access-control-allow-credentials': credentials,
})
Expand Down

0 comments on commit c1721e0

Please sign in to comment.