问题描述
限时送ChatGPT账号..我正在尝试访问 post 方法中的数据,它的名称是 Login() 但是当 URL 传输到它的位置时会产生错误.
I am trying to access data within post method and its name is Login() but when URL is transfer to its location at that time Error is generated.
错误:-拒绝连接'http://smartlearner/SmartLearner/UserAccount/LearnerLoginByMobileApp?Email=abc@gmail&Password=12345&crossDomain=true'因为它违反了以下内容安全策略指令:"default-src 'self' 数据:gap: https://ssl.gstatic 'unsafe-eval'".请注意,'connect-src' 没有明确设置,所以 'default-src' 是用作后备.
Error:-Refused to connect to 'http://smartlearner/SmartLearner/UserAccount/LearnerLoginByMobileApp?Email=abc@gmail&Password=12345&crossDomain=true' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
我打包了 "Allow-Control-Allow-Origin
: *" 扩展并将其安装到 chrome 中,但它不起作用.
I packed the "Allow-Control-Allow-Origin
: *" extension and installed it into chrome but it does not work.
代码
$scope.Login = function (callback) {
$http({
method: "Post",
url: "http://smartlearner/SmartLearner/UserAccount/LearnerLoginByMobileApp",
params: {
Password: $('#Password').val(),
Email: $('#Email').val(),
crossDomain: true
}
}).success(function (data) {
//Do Something here
}, callback)
.error(function (data, errorThrown) {
//Do Something here
}, callback);
};
推荐答案
您需要安装白名单插件 允许在您的 Cordova 应用程序中支持 XHR.没有它,您就无法发出外部请求.
You need to install the whitelist plugin to allow XHR support in your Cordova app. You can't make external requests without it.
运行:cordova plugin add https://github/apache/cordova-plugin-whitelist.git
这篇关于拒绝连接到 [Any Url],因为它违反了以下内容安全策略指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论