“找不到内容安全策略元标签”。错误在我的phonegap应用程序 [英] "No Content-Security-Policy meta tag found." error in my phonegap application

查看:174
本文介绍了“找不到内容安全策略元标签”。错误在我的phonegap应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新Cordova 5.0在我的系统中,我创建新的应用程序。当我在设备上测试我的应用程序时,我在控制台日志中收到错误:

After update Cordova 5.0 in my system I create new applications. When I tested my application in device that time I get an error in the console log:

No Content-Security-Policy meta tag found.
Please add one when using the Cordova-plugin-whitelist plugin.: 23.

在头部添加元

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'>

但是,同样的,我在应用程序中使用了inappbrowser插件和其他7个网站链接。

But again, I got the same error, in my application I use inappbrowser plugin and 7 of other website links.

推荐答案

添加 cordova-plugin-whitelist 后,您必须告知应用程序

After adding the cordova-plugin-whitelist, you must tell your application to allow access all the web-page links or specific links, if you want to keep it specific.

您可以简单地将它添加到您的 config.xml ,可在应用程序的根目录中找到:

You can simply add this to your config.xml, which can be found in your application's root directory:

推荐

<allow-navigation href="http://example.com/*" />

或:

<allow-navigation href="http://*/*" />

从插件的文档:


导航白名单

控制可以导航到WebView本身的URL。仅适用于
顶级导航。

Controls which URLs the WebView itself can be navigated to. Applies to top-level navigations only.

Quirks:在Android上,它也适用于非http(s)方案的iframe。

Quirks: on Android it also applies to iframes for non-http(s) schemes.

默认情况下,只允许导航到file:// URLs。要允许
其他其他URL,您必须向您的
config.xml中添加标签:

By default, navigations only to file:// URLs, are allowed. To allow other other URLs, you must add tags to your config.xml:

<!-- Allow links to example.com -->
<allow-navigation href="http://example.com/*" />

<!-- Wildcards are allowed for the protocol, as a prefix
     to the host, or as a suffix to the path -->
<allow-navigation href="*://*.example.com/*" />

<!-- A wildcard can be used to whitelist the entire network,
     over HTTP and HTTPS.
     *NOT RECOMMENDED* -->
<allow-navigation href="*" />

<!-- The above is equivalent to these three declarations -->
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />


这篇关于“找不到内容安全策略元标签”。错误在我的phonegap应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆