0034-00000002

更新时间:
复制 MD 格式

Problem description

The PutBucketCors request failed because the XML body contains no <CORSRule> element. A valid cross-origin resource sharing (CORS) configuration requires at least one rule.

Causes

The XML body passed to PutBucketCors contains only an empty <CORSConfiguration> element with no <CORSRule> child. OSS rejects the request because a CORS configuration without any rule has no effect.

Examples

The following request triggers this error:

PUT /?cors HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 186
Date: Fri, 04 May 2012 03:21:12 GMT
Authorization: OSS qn6q**************:77Dv****************

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
</CORSConfiguration>

The <CORSRule> element is missing, so OSS has no rule to apply and returns this error.

Solutions

Add at least one <CORSRule> element inside <CORSConfiguration>. Each rule must specify which origins, HTTP methods, and headers are allowed.

PUT /?cors HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 186
Date: Fri, 04 May 2012 03:21:12 GMT
Authorization: OSS qn6q**************:77Dv****************

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
    <CORSRule>
      <AllowedOrigin>*</AllowedOrigin>              <!-- Allowed request origins; * permits all origins -->
      <AllowedMethod>PUT</AllowedMethod>             <!-- Allowed HTTP methods -->
      <AllowedMethod>GET</AllowedMethod>
      <AllowedHeader>Authorization</AllowedHeader>   <!-- Allowed request headers -->
    </CORSRule>
    <ResponseVary>false</ResponseVary>               <!-- Whether OSS returns the Vary: Origin header -->
</CORSConfiguration>

References