我不知道这是否是AngularJS中的错误,或者如果我需要配置的东西。从我的理解,XHR包装器不能做一个OPTIONS HTTP请求,所以它看起来像浏览器试图找出是否“允许”下载资源首先执行GET请求。如果是这样,那么我需要为资产主机设置CORS头(Access-Control-Allow-Origin:http://asset.host …)吗?
@H_404_3@The Cross-Origin Resource Sharing standard works by adding new HTTP
headers that allow servers to describe the set of origins that are
permitted to read that information using a web browser. Additionally,
for HTTP request methods that can cause side-effects on user data (in
particular; for HTTP methods other than GET,or for POST usage with
certain MIME types). The specification mandates that browsers
“preflight” the request,soliciting supported methods from the server
with an HTTP OPTIONS request header,and then,upon “approval” from
the server,sending the actual request with the actual HTTP request
method. Servers can also notify clients whether “credentials”
(including Cookies and HTTP Authentication data) should be sent with
requests.
很难提供一个适用于所有WWW服务器的通用解决方案,因为设置将根据您打算支持的服务器本身和HTTP动词而有所不同。我建议您阅读这篇有关需要由服务器发送的确切标题的更多详细信息的优秀文章(http://www.html5rocks.com/en/tutorials/cors/)。
@H_404_3@ 原文链接:https://www.f2er.com/angularjs/147782.html