Configuring CORS

This section describes how to use CORS in HTML5 to implement cross-origin access.


Static website hosting has been enabled.


  1. Log in to OBS Console.
  2. In the bucket list, click the target bucket to go to the Summary page.
  3. In the navigation tree on the left, click Static Website Hosting.
  4. Click the CORS Rule card.
  5. Click Add, as shown in Figure 1.


    You can set a maximum of 100 CORS rules for OBS.

    Figure 1 CORS Rule

  6. In the CORS Rule dialog box, configure Allowed OriginAllowed MethodAllowed HeaderExposed Header, and Cache Duration (s).

    Table 1 describes the parameters of CORS rules.

    Table 1 Parameters in CORS rules



    Allowed Origin


    Requests from this origin can access the bucket.

    Multiple matching rules are allowed. One rule occupies one line, and allows one wildcard character (*) at most. For example:

    Allowed Method


    Specifies the acceptable operation type of buckets and objects.

    The methods include GET, POST, PUT, DELETE, and HEAD.

    Allowed Header


    Specifies the allowed header of cross-origin requests.

    Only CORS requests matching the allowed header are valid.

    You can enter multiple allowed headers (one per line) and each line can contain one wildcard character (*) at most. Spaces and special characters including &:< are not allowed.

    Exposed Header


    Specifies the exposed header in CORS responses, providing additional information for clients.

    You can enter multiple exposed headers (one per line). Spaces and special characters including *&:< are not allowed.

    Cache Duration (s)


    Specifies the duration that your browser can cache CORS responses, expressed in seconds. The default value is 100.

  7. Click OK.

    A message is displayed indicating that CORS configuration of the bucket is successful. The configuration of CORS takes effect within two minutes.

    After CORS is successfully configured, only the addresses specified in Allowed Origin can access a bucket on OBS using the method specified in Allowed Method. For example, you configure CORS parameters of bucket testbucket as follows:

    • Allowed
    • Allowed MethodGET
    • Allowed Header: left blank
    • Exposed Header: left blank
    • Cache Duration (s)100

Follow-up Procedure

You can click Edit or Delete to edit or delete a configured CORS rule based on site requirements.