1

我正在用cordova构建应用程序。我正在使用phonegap serve通过phonegap开发人员应用程序加载应用程序。Phonegap应用程序内容安全策略

index.html

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

(我也试过没有file: tel:,结果是一样的)

我可以确认这是platforms/browser/www/index.html

正确处理然后我打开的PhoneGap在iPad上运行应用程序,我运行phonegap serve,我打开Safari开发工具,按连接,它就是:

Refused to load gap://ready because it appears in neither the child-src directive nor the default-src directive of the Content Security Policy. 

index.html我可以看到,该指令已转化为:

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

有没有一种方法,使iPad的正确加载指令?

编辑

我也试图编译PhoneGap的应用程序开发者与CSP指令在index.html,结果是一样的

编辑 - 1

我还下载了从http://192.168.1.130:3200/__api__/appzip(这是我有我的phonegap serve服务器)和index.html已经转换的zip文件!

这里的奇怪之处在于platforms/browser/www/index.html没有被转换,所以在转换CSP的过程中存在一些过程。

在我​​3210我有这个指令:

<content src="index.html" /> 
<access origin="*" /> 
<access origin="cdvfile://*" /> 
<access launch-external="yes" origin="tel:*" /> 

<!-- Allowed WebView navigations --> 
<allow-navigation href="http://*"/> 
<allow-navigation href="https://*"/> 
<allow-navigation href="http://*/*"/> 
<allow-navigation href="https://*/*"/> 
<allow-navigation href="data:*"/> 
<allow-navigation href="about:*"/> 
<allow-navigation href="tel:*"/> 
<allow-navigation href="gap:*" /> 
<!-- Allowed URLs to be opened from the app --> 
<allow-intent href="http://*"/> 
<allow-intent href="https://*"/> 
<allow-intent href="http://*/*"/> 
<allow-intent href="https://*/*"/> 
<allow-intent href="geo:*"/> 
<allow-intent href="cdvfile://*" /> 
+0

你有任何插件吗?也许一些插件会覆盖meta标签。 –

回答

0

它是与此相关的问题:https://github.com/creationix/nvm/issues/1361

主要,的bash检测到v6.4.2,并指着它(which phonegap指着正确的版本),但是从命令行执行phonegap时,它正在执行v6.0.2,可能没有设置正确的CSP。