我有一个AngularJS应用,我需要将数据发布到第三方URL,该URL用于在第三方服务器上存储一些数据.当我在下面运行我的代码时,出现以下错误: XMLHttpRequest无法加载 thirdparty.url/.对预检请求的响应未通过访问控制检查:在所请求的资源上不存在"Access-Control-Allow-Origin"标头.因此,不允许访问来源' localhost:51491 .
I have an AngularJS app that I need to post data to a third party URL which is used to store some data on the third party server. I get the following error when I run my code below: XMLHttpRequest cannot load thirdparty.url/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:51491' is therefore not allowed access.
我在AngularJS工厂中运行的代码是:
The code I'm running in my AngularJS factory is:
return $http({ url: '//thirdparty.url', method: "POST", data: params_string, headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' } });推荐答案
这意味着您的 thirdparty.url / 不接受来自 thirdparty.url/的外部来源的请求,因此,您必须从您的thirdparty.url
This means that your thirdparty.url/ Does not accept requests from external sources that is/are not from thirdparty.url/, so you have to enable it from your thirdparty.url
更多推荐
AngularJS没有'Access
发布评论