显然,我完全误解了它的语义.我想到了这样的事情:
好吧,我错了.它根本不起作用.所以,我已经阅读了跨源资源共享,并尝试在w3c推荐中阅读跨源资源共享
有一件事是肯定的 - 我仍然不明白我应该如何使用这个标题.
我完全控制了站点A和站点B.如何启用从站点A下载的javascript代码以使用此标头访问站点B上的资源?
PS
我不想使用JSONP.
尝试从Amazon S3服务器加载图像(将crossorigin设置为匿名)后,我们仍然遇到可怕的错误:
XMLHttpRequest cannot load
http://resource-url No
'Access-Control-Allow-Origin' header is present on the requested resource. Origin
'http://server-url' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
我们已经尝试了几种CORS配置,例如
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
以及Amazon的默认CORS配置。仍然,同样的错误。
其他一些注意事项:
curl -XGET -H 'Origin: anonymous' http://resource-url 返回看起来像是图像,从 ?PNG我尽力了,因此,不胜感激。非常感谢!