Foursquare返回“ No access control allow origin”标头存在错误

巴拉

我正在对Foursquare OAuth URL进行GET调用。浏览器控制台显示以下错误

XMLHttpRequest cannot load https://foursquare.com/oauth2/authenticate?client_id=DF4I1TGNVHAM40PDLOHZQZ…onse_type=code&redirect_uri=http://localhost:9000/auth/foursquare/callback. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.

这是拨打电话的代码段:

$http.get(url).success(function(data,status,headers,config){
});

但是,如果我将按钮链接到该URL,浏览器会将我带到身份验证页面。

有什么区别?为什么当URL链接到按钮时它起作用,为什么当对该URL进行GET调用时它不起作用?

韦恩·埃勒里(Wayne Ellery)

除非服务器提供Access-Control-Allow-Origin(CORS)标头,否则Ajax不允许从一个域到另一个域的请求。域之间的链接是允许的。

Mozilla对于允许和禁止的内容有一些很好的信息。https://developer.mozilla.org/zh-CN/docs/Web/Security/Same-origin_policy#Cross-origin_network_access

  • 通常允许跨域写入。例如链接,重定向和表单提交。某些很少使用的HTTP请求需要进行预检。
  • 通常允许跨域嵌入,例如图像,脚本。
  • 通常不允许跨域读取,例如ajax调用

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

反应使 axios 获取,返回错误:CORS 策略:请求的资源上不存在“Access-Control-Allow-Origin”标头

LinkedIn OAuth重定向登录返回“请求的资源上不存在'Access-Control-Allow-Origin'标头”错误

获取 CORS 错误而不是错误 500(不存在“Access-Control-Allow-Origin”标头)

存在“ Access-Control-Allow-Origin”标头

Cherrypy处理“不存在'Access-Control-Allow-Origin'标头”错误

JSONP跨源错误“不存在Access-Control-Allow-Origin标头”

请求的资源错误中不存在“ Access-Control-Allow-Origin”标头

提取错误所请求的资源上不存在“ Access-Control-Allow-Origin”标头

某些请求出现“不存在'Access-Control-Allow-Origin'标头”错误

错误:CORS 政策:ionic 4 中不存在“Access-Control-Allow-Origin”标头

vue socket.io连接尝试返回“没有'Access-Control-Allow-Origin'标头不存在”错误,即使已设置来源

获取Access-Control-Allow-Origin标头错误

从服务器返回401响应时,请求的资源上不存在“ Access-Control-Allow-Origin”标头

无法进行本地开发并出现错误:请求的资源上不存在“ Access-Control-Allow-Origin”标头

Yii2 cors过滤器错误,提示不存在“ Access-Control-Allow-Origin”标头

3xx重定向,“请求的资源上不存在'Access-Control-Allow-Origin'标头”错误

请求的资源错误中不存在“Access-Control-Allow-Origin”标头。请求成功但触发失败

AJAX请求获取“所请求的资源上不存在“ Access-Control-Allow-Origin”标头”错误

出现错误“请求的资源上不存在‘Access-Control-Allow-Origin’标头。” 在离子2

在提取API django中请求的资源错误中不存在“ Access-Control-Allow-Origin”标头

如何解决nodejs中的CORS错误“不存在'Access-Control-Allow-Origin'标头”?

React 和 Yii2 连接错误 - 请求的资源上不存在“Access-Control-Allow-Origin”标头

即使在服务器和客户端上设置标头后,也会出现错误“请求的资源上不存在 'Access-Control-Allow-Origin' 标头”

当请求中的Origin标头存在时,AWS S3不发送Access-Control-Allow-Origin标头

光纤 CORS 中间件返回 null Access-Control-Allow-Origin 标头值

哪个服务器需要返回Access-Control-Allow-Origin标头?

Reddit API / api / morechildren使用mootools返回“ No'Access-Control-Allow-Origin'标头”

azure删除了从我的应用程序服务返回的Access-Control-Allow-Origin标头

Meteor 和 Socket IO - 不存在“Access-Control-Allow-Origin”标头