Chrome 不允许向允许的域发出 Ajax 请求
我正在创建我的第一个 Chrome 扩展程序,一个相对简单的扩展程序,带有一些 ajax 调用。
我的清单非常简单:
{
"name": "Read It Now",
"version": "0.12",
"description": "Read it now.",
"permissions": [
"https://readitlaterlist.com"
],
"app": {
"launch": {
"local_path": "index.html"
}
}
}
然后我使用 jQuery 从 URL 中获取一些简单的数据,例如:
https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz
但是,Chrome 仍然拒绝它:
XMLHttpRequest 无法加载 https://readitlaterlist.com /v2/get?state=unread&count=10&apikey=xxx&用户名=yyy&密码=zzz。 来源 chrome-extension://cdfeahailioembamnjnikbiemengfgpp 不是 由 Access-Control-Allow-Origin 允许。
I'm creating my first Chrome extension, a relatively simple one with some ajax calls.
My manifest is pretty simple:
{
"name": "Read It Now",
"version": "0.12",
"description": "Read it now.",
"permissions": [
"https://readitlaterlist.com"
],
"app": {
"launch": {
"local_path": "index.html"
}
}
}
I'm then using jQuery to fetch some simple data from a URL like:
https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz
However, Chrome still rejects it:
XMLHttpRequest cannot load
https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz.
Origin chrome-extension://cdfeahailioembamnjnikbiemengfgpp is not
allowed by Access-Control-Allow-Origin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在网址匹配模式中包含该路径。
"https://readitlaterlist.com/*"
应该可以解决您的问题。You have to include the path in your URL match pattern.
"https://readitlaterlist.com/*"
should fix your problem.