gpt4 book ai didi

javascript - Chrome 打包应用程序中的 https 请求(javascript)

转载 作者:行者123 更新时间:2023-11-30 17:37:57 25 4
gpt4 key购买 nike

我正在尝试从 chrome 打包应用程序发送请求:

$.ajax({
url: "https://accounts.google.com/o/oauth2/auth?client_id=xxxapps.googleusercontent.com&response_type=id_token&scope=openid%20email", //"https://www.googleapis.com/plus/v1/people/me",

jsonp: "responseText",

dataType: "jsonp",

data: {
q: "select *",
format: "json"
},

success: function( response ) {
console.log( response );
}
});

并收到以下错误:

Refused to load the script
'https://accounts.google.com/o/oauth2/auth?client_id=xxx&q=select+*&format=json&_=xxx'
because it violates the following Content Security Policy directive:
"default-src 'self' chrome-extension-resource:". Note that
'script-src' was not explicitly set, so 'default-src' is used as a fallback.

应用程序的 list 文件包含以下内容:

   "content_security_policy": "script-src 'self' https://accounts.google.com; object-src 'self'"

如何解决这个错误?

最佳答案

您看到的错误消息就是答案。第一个说你违反了 CSP。第二个是说您不能在 Chrome 应用中更改 CSP。

阅读更多关于 Content Security Policy in a Chrome App 的信息, 为了完整性 another discussion in the context of Chrome Extensions .您已经找到所问问题的答案,但您可能想问一个新问题来解释您正在尝试做什么(而不是为什么会看到这些错误消息)。如果您的总体目标是在 Chrome 应用程序中运行外部(即下载的)内容,根据 Chrome 网上应用店的开发人员服务条款,唯一的方法是将代码和消息沙盒化到/从您的普通特权代码.

关于javascript - Chrome 打包应用程序中的 https 请求(javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21657311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com