AngularJS没有'Access

编程入门 行业动态 更新时间:2024-10-28 16:23:34
本文介绍了AngularJS没有'Access-Control-Allow-Origin'标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个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

本文发布于:2023-11-24 19:11:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626473.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AngularJS   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!