1. 程式人生 > >【odoo10】Refused to execute script from '*' because its MIME type ('text/plain') is not executable

【odoo10】Refused to execute script from '*' because its MIME type ('text/plain') is not executable

軟體環境:window10

編譯環境:python2.7.9,pycharm4.5.3 ,nodejs6.9

問題描述:當開發環境搭建成功,啟動odoo9或者odoo10後(已建立資料庫),登陸訪問報錯如下

web:1 Refused to execute script from '*/web.assets_common.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled


問題截圖如下

分析服務端在Response中設定了X-Content-Type-Options:nosniff

 ,告訴瀏覽器強制檢查資源的MIME,進行載入,

但是,web.assets_common.js原本就是js檔案,瀏覽器把該檔案當作“純文字”(file.content_type:text/plain)解析。

故用任何瀏覽器都會報錯。

原因:可能是pycharm或者nodejs 合併壓縮JS過程中,把檔案型別改成了text/plain;這個過程我還不知道什麼原因,後續瞭解了,再補充。

解決方案

查詢資料庫找到後臺返回的檔案型別text/plain
select * from ir_attachment where mimetype ='text/plain' and datas_fname like '%.js';

把mimetype欄位的值:text/plain 改為 text/javascript