我有一个S3存储桶,我希望允许2个域访问资源:
http://asubdomain.mysite.com
http://localhost:3000
这是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.