2016-07-25 77 views
0

,我得到以下錯誤:谷歌地圖API錯誤「爲由,拒絕加載字庫」我使用谷歌地圖在我angular2/Ionic2應用

js?libraries=geometry,drawing,places:79 Refused to load the font ' https://fonts.gstatic.com/s/roboto/v15/isZ-wbCXNKAbnjo6_TwHThJtnKITppOI_IvcXXDNrsc.woff2 ' because it violates the following Content Security Policy directive: "font-src 'self' data:".

這是什麼錯誤,我怎麼能解決這個問題?

index.html有:

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

<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry,drawing,places"></script> 

卸下meta標籤解決了這個問題,但我不知道它做什麼,以及是否我應該將其刪除。

回答

0

這不是關於內聯javascript,而是內聯樣式標記。要麼你有他們(可能不),或者你正在使用的東西(可能是一個jQuery插件),正在添加它們。根據此blog,您需要通過將https://github.com/rwjblue/ember-cli-content-security-policy#options的配置添加到您的config/environment.js中來啓用它。

默認contentSecurityPolicy值是:

contentSecurityPolicy: { 
    'default-src': ["'none'"], 
    'script-src': ["'self'"], 
    'font-src': ["'self'"], 
    'connect-src': ["'self'"], 
    'img-src':  ["'self'"], 
    'style-src': ["'self'"], 
    'media-src': ["'self'"] 
    } 

檢查這些相關鏈接:Violating Content Security Policy directive after ember-cli 0.0.47 upgrade"[Report Only] Refused to load the font..." error message on console