简体   繁体   English

Apache Cordova:CSP错误

[英]Apache Cordova: CSP Error

I have a problem with the Android 5.0 Lollipop and Google Maps Api, i have an CSP Error of unsafe-eval. 我在使用Android 5.0 Lollipop和Google Maps Api时遇到问题,我遇到了不安全评估的CSP错误。

Here is the Error: 这是错误:

https://maps.googleapis.com/maps-api-v3/api/js/22/7/intl/es_ALL/main.js:65 https://maps.googleapis.com/maps-api-v3/api/js/22/7/intl/es_ALL/main.js:65

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src * 'unsafe-inline'". Uncaught EvalError:拒绝将字符串评估为JavaScript,因为在以下内容安全策略指令“ default-src *'unsafe-inline'”中不允许使用'unsafe-eval'作为脚本源。

The Code: 编码:

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

Inside my config.xml i have this: 在我的config.xml中,我有这个:

    <plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*" />

I have no problems with Android 4.x but just only with 5.x, i know it's because of the Chromium Webview but i can't use the Google Maps because of this error. 我对Android 4.x没问题,而对5.x没问题,我知道这是由于Chromium Webview造成的,但是由于这个错误,我无法使用Google Maps。

What can i do to fix this ? 我该怎么做才能解决此问题?

Thanks ! 谢谢 !

尝试稍微重构一下您的Content-Security-Policy元标记,在使用Google Maps的Cordova 5 / Android 5应用中,我可以进行以下操作(位置与您不同:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM