From c1721e08918aa9a0fb538ecdcdab6e16c3adc548 Mon Sep 17 00:00:00 2001 From: nicolasvienot Date: Thu, 27 Jun 2024 12:00:10 +0200 Subject: [PATCH] fix: corsify issue "can't modify immutable headers" --- src/cors.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cors.ts b/src/cors.ts index 9b08608..9f6a2dd 100644 --- a/src/cors.ts +++ b/src/cors.ts @@ -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, })