S3 CORS不允许两个域的来源

时间:2014-03-05 08:59:58

标签: amazon-s3 cors

我有一个S3存储桶,我希望允许2个域访问资源:

  1. http://asubdomain.mysite.com
  2. http://localhost:3000
  3. 这是CORS规则:

    <?xml version="1.0" encoding="UTF-8"?>
    <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
        <CORSRule>
            <AllowedOrigin>http://asubdomain.mysite.com</AllowedOrigin>
            <AllowedMethod>GET</AllowedMethod>
            <MaxAgeSeconds>3000</MaxAgeSeconds>
            <AllowedHeader>*</AllowedHeader>
        </CORSRule>
        <CORSRule>
            <AllowedOrigin>http://localhost:3000</AllowedOrigin>
            <AllowedMethod>GET</AllowedMethod>
            <MaxAgeSeconds>3000</MaxAgeSeconds>
            <AllowedHeader>*</AllowedHeader>
        </CORSRule>
    </CORSConfiguration>
    

    然而,当我尝试访问页面上的资源时,偶尔会出现此错误。有什么想法吗?

    XMLHttpRequest cannot load https://s3.amazonaws.com/my_awesome_bucket/myfile.txt. 
    The 'Access-Control-Allow-Origin' header has a value 'http://localhost:3000' that is not equal to the supplied origin. 
    Origin 'http://asubdomain.mysite.com' is therefore not allowed access. 
    

0 个答案:

没有答案