Purge CORS resource by single file url

Hi all.

I faced a problem when the cached CORS resource (the one that was requested with Origin header) was not invalidated when I called purge by single file endpoint. I tried to add the Origin header to the purge request but it didn’t solve the problem.

I don’t have any custom cache key configuration applied and the default settings are used instead.

The endpoint works fine for the common request but it doesn’t purge the cache for the CORS requests (with the Origin header).

Here is the screenshot of the response headers after that specific request was invalidated.

Okay, I found the problem.

The Origin header should not be added to the request HTTP headers but should be passed in the body payload like this:

"files": [{
  "url": "https://my-site.com/test.js",
  "headers": {
    "Origin": "https://my-site.com"

That’s weird that there is no mention of this in the official documentation… Cloudflare API Documentation