R2 has stopped working! Cors policy has changed?

Pre-sign the URL in the backend
And I use XMLHttpRequest on the front to send the files.

Everything was working perfectly with this Cors configuration:

[
   {
     "AllowedOrigins": [
       "https://mysite.com", 
       "http://localhost:4000"
     ],
     "AllowedMethods": [
       "GET",
       "PUT"
     ],
     "AllowedHeaders": [
       "content-type",
       "Content-Length"
     ]
   }
]

It stopped working and shows the following message:

Access to XMLHttpRequest at ‘=URL Presigned’ from origin ‘http://localhost:4000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

when I change

 "AllowedOrigins": [
       "*"
     ],

I have the same error!

Before it worked perfectly!

What to do?

The problem may be with the expired token!
Generated new access token and modified cors rules

Everything worked again!

I would have liked to have been alerted by the API that my Token was expired.
It would save you trouble.

Cors rules:

[
  {
    "AllowedOrigins": [
      "mysite.com","localhost:4000"
    ],
    "AllowedMethods": [
      "GET",
      "PUT",
      "HEAD"
    ],
    "AllowedHeaders": [
      "content-type",
      "Content-Length"
    ],
    "ExposeHeaders": [
      "Content-Type",
      "Access-Control-Allow-Origin",
      "ETag",
      "Cache-Control",
      "Content-Disposition",
      "Content-Encoding",
      "Expires"
    ]
  }
]

https://dash.cloudflare.com/
r2
Manage R2 API Tokens
new token

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.