0

我製作了Chrome擴展程序並使用Firebase將數據收集到數據庫中。 它在一段時間內運行良好,但似乎Chrome瀏覽器發生了一些變化。 現在使用檢查元素在我的擴展,當我在JavaScript控制檯以下錯誤:如何在Chrome擴展程序Manifest.json中設置內容安全策略以使Firebase發揮作用

拒絕加載腳本「https://(myID).firebaseio.com/(otherprivatedata)」,因爲它違反了以下內容安全政策指令:「腳本的src‘自我’鉻擴展資源」。

這個腳本寫在firebase.js:171,它不是我添加的腳本。

我試圖按照本指南和「content_security_policy」標籤添加到我的manifest.json的指示: https://github.com/firebase/firebase-chrome-extension

添加以下行到我的manifest.json的指示:

"content_security_policy": "script-src 'self' https://cdn.firebase.com https://*.firebaseio.com; object-src 'self'" 

但是,當我添加此行時,我現在嘗試在chrome中加載腳本時遇到錯誤:// extensions

Error Loading Exte nsion

無法從加載擴展:〜\ XXX \ my_ext

清單無效JSON。行:14,列:5,語法錯誤。

它突出了我剛纔在上面添加的內容(content_security_policy)。 我在做什麼錯? Chrome完全拒絕「content_security_policy」之後的任何內容。

即使當我嘗試谷歌示例代碼時,它也不起作用。 developer.chrome.com/extensions/contentSecurityPolicy

"content_security_policy": "script-src 'self' https://example.com; object-src 'self'" 

我如何可以設置content_security_policy爲了火力地堡中的擴展工作?

(我firebase.jp已經下載並封裝在與我的擴展,因爲Chrome瀏覽器不會讓我把它作爲遠程)

+1

包含您的完整manifest.json。可能在某處存在額外或缺失的逗號。 – rsanchez

回答

1

是的,感謝rsanchez ......完全忘了一個逗號...

... 
"options_page": "option.html", 
    "manifest_version": 2, <- THIS COMMA 
    "content_security_policy": "script-src 'self' https://cdn.firebase.com https://*.firebaseio.com; object-src 'self'" 
} 

現在就工作,感謝您的幫助!

相關問題