How can we remove cookies from request to avoid being sent to origin?


We are trying to delete a cookie from workers to avoid being sent to origin.

Uncaught (in promise) TypeError: Can’t modify immutable headers.
at handleRequest (worker.js:23:19)
at event (worker.js:2:21)

Is it not possible to delete a cookie/header from request? All the example recipes available on this portal show examples to modify the response headers not the request.

Your inputs are highly appreciated.


You should be able to clone the request.

Perhaps you can share a code snippet?

You need to clone the request before modifying it. Try this:

const newResponse = new Response(response.body, response)
return newResponse
1 Like