Quora 简单 API 和跨域源错误?
我正在使用 Quora 的 API。
我找到了 quora 浏览器扩展的 github 存储库 [https://github.com/drusepth/Quora-Chrome-Extension/blob/master/stable/background.html],它看起来就像执行 GET of http://api.quora.com/api/logged_in_user?fields=notifs,inbox。这应该返回相关的 JSON。
但是当我在本地网页上尝试相同的代码时,我得到了这个:
Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
为什么会发生这种情况?我该如何解决这个问题?
I'm playing around with Quora's API.
I found this github repository for a quora browser extension [https://github.com/drusepth/Quora-Chrome-Extension/blob/master/stable/background.html], and it seems as easy as doing a GET of http://api.quora.com/api/logged_in_user?fields=notifs,inbox. And that should return the relevant JSON.
But when I try the same code from a local web page, I get this:
Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
Why does this happen? And how can I work around it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 api.quora.com 域添加到 manifest.json 文件的权限部分。有关更多详细信息,请参阅此处: http:// /monsur.hossa.in/2011/07/07/chrome-extensions-and-cross-domain-requests.html
You need to add the api.quora.com domain to the permissions section of your manifest.json file. See here for more details: http://monsur.hossa.in/2011/07/07/chrome-extensions-and-cross-domain-requests.html