CORS (Cross-Origin Resource Sharing) is a browser security mechanism that defines whether a site can access resources from another origin. S3 Object Storage can generate CORS errors when a website or web application is retrieving, uploading, or accessing files stored in a Space.
Suppose your website is https://example.com and you want to load an image from another storage endpoint . The browser checks if this is allowed to be loaded cross origin .
Origin not allowed: The domain for the website is not included in the storage CORS configuration.
Not allowed HTTP method: The requested method is not allowed by the configuration (e.g. GET or PUT)
Request headers not permitted: The browser is sending headers that are not allowed by the CORS policy.
Preflight request failed: The browser makes a preflight request (OPTIONS) before the actual request, but the server does not respond with the required response.
Authentication or permission errors: The request has not been made with proper credentials or permission to access the object. CORS errors may sometimes be associated with these errors.
Wrong endpoint or object URL: The application sends the query to the wrong storage endpoint or object location.
Open your website in a browser and press F12 to open Developer Tools. Select the Console tab and reproduce the error.
The message may indicate whether the origin, request method, headers, or preflight request is causing the problem.
Check the origin of the website making the request. An origin includes the protocol, domain, and port.
For example, https://example.com and http://example.com are different origins. Similarly, https://app.example.com and https://example.com are different origins.
The storage CORS configuration must allow the origin used by your application.
Make sure the CORS rules allow the HTTP method required by your application.
Common methods include:
GET for retrieving files.
HEAD for retrieving object metadata.
PUT for uploading files.
DELETE for deleting files, when supported by the application.
Allowing a method through CORS does not automatically grant permission to perform that action. Storage permissions must also allow it.
Some requests include headers such as Content-Type, Authorization, or S3-compatible request headers. If the browser requests permission to send headers that the CORS configuration does not allow, the request may fail.
Use the browser's Network tab to inspect the failed request and identify the headers involved.
For certain cross-origin requests, the browser sends an OPTIONS request before sending the actual request.
If this preflight request fails, check whether the storage service returns the required CORS headers and allows the requested origin, method, and headers.
If your storage panel supports CORS settings, verify the allowed origins, methods, and request headers. Include only the origins and operations required by your application.
If the panel does not provide CORS settings, check whether configuration through a supported S3-compatible client or API is available.
Confirm that the application uses the correct storage endpoint and object key. Also check whether the file exists and whether the request has permission to access it.
A missing object or a 403 Forbidden response may be accompanied by a CORS error if the response does not include the expected CORS headers.
Error or symptom | What to check |
|---|---|
| Verify the allowed origin and response headers. |
Preflight request failed | Check the |
Method not allowed | Confirm the required method is included in the CORS rules. |
Request header not allowed | Check the headers requested by the browser. |
File works through a direct link but not in the website | Check the website's origin and the storage response's CORS headers. |
CORS error with a | Check object permissions, credentials, and response headers. |
CORS is enforced by browsers; it is not a replacement for authentication or storage permissions.
Making a Space or file public is not a general solution to CORS errors.
Credentialed browser requests cannot use Access-Control-Allow-Origin: *.
If a website uses a CDN or proxy, its configuration may also affect the response.
After changing CORS settings, test the request again and inspect the response headers in Developer Tools.
Security note: Never expose secret access keys, passwords, or authorization tokens in browser-side code or while sharing troubleshooting details.