kwhitley / itty-router

A little router.
MIT License
1.69k stars 77 forks source link

fix: corsify issue "can't modify immutable headers" #252

Open nicolasvienot opened 1 week ago

nicolasvienot commented 1 week ago

Description

A fix was implemented in https://github.com/kwhitley/itty-router/commit/74f63abb25d12666e7c05e5e82fcf7432f8dbda4 to clone the response in corsify in order to avoid this error:

{
  "status": 500,
  "error": "Can't modify immutable headers."
}

Unfortunately, it seems not to be enough, and we're still having the issue with Cloudflare when a response is modified by corsify. A solution we found and implemented is to recreate a response by using new Response(...).

Applying the fix here.

Related Issue

Link to the related issue: related to #242

Type of Change (select one and follow subtasks)

nicolasvienot commented 1 week ago

I can open a new issue if needed, please let me know 👍 it might also be related to: https://github.com/kwhitley/itty-router/issues/249