CORS configuration for buckets
Object Storage allows you to manage bucket CORS configurations. To upload a CORS configuration to Object Storage, you need to create an XML document as described in this section. You can get a document in this format by downloading an existing configuration.
The general configuration format is as follows:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>URL</AllowedOrigin>
<AllowedMethod>HTTP_Method</AllowedMethod>
<AllowedHeader>Header_Name</AllowedHeader>
...
</CORSRule>
...
</CORSConfiguration>
A configuration may contain up to 100 rules.
Elements
|
Element |
Description |
|
|
Root element of a CORS configuration. It cannot contain more than 100 Path: |
|
|
Rule for filtering incoming requests to the resource. Each rule must contain at least one Path: |
|
|
Unique rule ID (maximum 255 characters). It is optional. You can use it to search for a rule in a file. Path: |
|
|
HTTP method ( Path: |
|
|
Website that allows sending CORS requests to the bucket. Specify at least one It may contain only one Path: |
|
|
Header allowed in a request to an object. If multiple headers are allowed, specify each one in a separate The options request contains the Path: |
|
|
Time, in seconds, for the browser to cache the result of request to an object using the options method. Path: |
|
|
Header that can be exposed to browser JavaScript apps. If multiple headers are allowed, specify each of them in a separate element. When sending a request to an object, the JavaScript client can only use the headers specified in the Path: |
Example
The following configuration allows you to send CORS requests from the http://www.example.com website using the PUT, POST, and DELETE methods without any header restrictions.
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>http://www.example.com</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>