Cap*_*gan 5 javascript cors angularjs
我有一个 AngularJS 应用程序,我需要将数据发布到第三方 URL,该 URL 用于在第三方服务器上存储一些数据。运行下面的代码时出现以下错误: XMLHttpRequest 无法加载http://thirdparty.url.com/。对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问Origin ' http://localhost:51491 '。
我在我的 AngularJS 工厂中运行的代码是:
return $http({
url: '//thirdparty.url.com',
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'
}
});
Run Code Online (Sandbox Code Playgroud)
这意味着您的http://thirdparty.url.com/ 不接受来自/不是来自http://thirdparty.url.com/ 的外部源的请求,因此您必须从您的thirdparty.url 启用它。 com
| 归档时间: |
|
| 查看次数: |
14682 次 |
| 最近记录: |