angularjs – 错误无法在’XMLHttpRequest’上执行’open’:拒
发布时间:2020-12-17 17:16:15 所属栏目:安全 来源:网络整理
导读:在离子中调用rest api时遇到错误. 如果我在浏览器firefox或chrome上运行,那么它工作正常.. 但是当我在 Android设备上运行时,它会出现以下错误: Error: Failed to execute 'open' on 'XMLHttpRequest': Refused to connectto 'http://192.168.XX.XXX:8080/Te
在离子中调用rest api时遇到错误.
如果我在浏览器firefox或chrome上运行,那么它工作正常.. 但是当我在 Android设备上运行时,它会出现以下错误: Error: Failed to execute 'open' on 'XMLHttpRequest': Refused to connectto 'http://192.168.XX.XXX:8080/TestApp/addRole/' becuase it violates the document's content security Policy at Error (native( at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:23357:16 我该如何解决这个问题 如果我在index.html中设置以下元标记如下,则在chrome和android设备中出现错误..不在firefox中 <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> 在我的休息服务上,我设置标题如下
我也安装了白名单插件,但没有运气 我该如何解决这个问题?请帮忙 解决方法
在Android上,您需要在< head>中设置content-security-policy元标记. @ index.html.
它看起来像这样: <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' data: gap: 'unsafe-eval'; style-src * 'self' 'unsafe-inline'; connect-src * ; script-src * 'self' 'unsafe-inline'; media-src *"> 在这种情况下,有许多不安全和不必要的标签几乎可以允许任何东西,但你可以在这里阅读更多关于它们的信息: Cordova whitelist plugin content security policy 在同一页面中还有其他内容的解释,如网络请求白名单. 希望这可以帮助您解决问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读