国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Refused to load the script ‘xxxx.js‘ because it violates the following Content Security Policy ...

這篇具有很好參考價(jià)值的文章主要介紹了Refused to load the script ‘xxxx.js‘ because it violates the following Content Security Policy ...。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

在使用Electron封裝一些模塊的時(shí)候,出現(xiàn)以下錯(cuò)誤:

Refused to load the script ‘https://unpkg.com/xxxx.js’ because it violates the following Content Security Policy directive: “script-src ‘self’ ‘unsafe-eval’ ‘unsafe-inline’ data:”. Note that ‘script-src-elem’ was not explicitly set, so ‘script-src’ is used as a fallback.

這是由于Electron為了防止出現(xiàn)XSS攻擊,阻止了該網(wǎng)站資源的加載,我們?cè)O(shè)置允許加載即可。

解決方法

例如,我們當(dāng)前被禁止的xxxx.js來(lái)自https://unpkg.com那么我們可以在electron程序的主進(jìn)程中添加如下代碼段

app.on('ready', () => {
  createWindow()
  session.defaultSession.webRequest.onHeadersReceived((details: Electron.OnHeadersReceivedListenerDetails, callback: (headersReceivedResponse: Electron.HeadersReceivedResponse) => void) => {
    callback({
      responseHeaders: {
        ...details.responseHeaders,
        'Content-Security-Policy': ['default-src \'self\' \'unsafe-inline\' \'unsafe-eval\'  https://unpkg.com'] // 注意這里的https://unpkg.com
      }
    })
  })
});

官方詳解:CSP解決方案文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-698538.html

到了這里,關(guān)于Refused to load the script ‘xxxx.js‘ because it violates the following Content Security Policy ...的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 使用pdfjs報(bào)錯(cuò):Failed to load module script: Expected a JavaScript module script but the server responded

    MIME 類型設(shè)置不正確: 服務(wù)器返回的文件 MIME 類型不正確。瀏覽器期望模塊腳本的 MIME 類型為 application/javascript。如果服務(wù)器返回的 MIME 類型不是這個(gè),瀏覽器會(huì)拒絕加載它,并顯示這個(gè)錯(cuò)誤 在nginx的默認(rèn)mime.types文件中沒(méi)有為mjs擴(kuò)展名設(shè)置條目,這意味著它將被作為applicati

    2024年04月27日
    瀏覽(29)
  • Failed to load module script: Expected a JavaScript module script but the server responded with a MI

    Failed to load module script: Expected a JavaScript module script but the server responded with a MI

    最近在使用slidev制作在線PPT,但是部署到nginx服務(wù)器上后,訪問(wèn)相應(yīng)的PPT網(wǎng)址,沒(méi)有現(xiàn)實(shí)404卻一直不顯示PPT的內(nèi)容。打開(kāi)控制臺(tái),發(fā)現(xiàn)錯(cuò)誤如下: 發(fā)現(xiàn)幾個(gè)需要的js和css文件缺失了(主要是js) 打開(kāi)網(wǎng)絡(luò)請(qǐng)求,乍一看沒(méi)問(wèn)題,但是每一個(gè)文件的實(shí)際請(qǐng)求一看,發(fā)現(xiàn)是發(fā)送的目

    2024年02月11日
    瀏覽(20)
  • Unity “Failed to create agent because it is not close enough to the NavMesh“警告 并由此引發(fā)的問(wèn)題

    Unity “Failed to create agent because it is not close enough to the NavMesh“警告 并由此引發(fā)的問(wèn)題

    這個(gè)報(bào)錯(cuò)表示的意思是:NavMeshAgent所在節(jié)點(diǎn)未放置在尋路網(wǎng)格上 從最基本的理解上,就是說(shuō)你的角色,或者某個(gè) agent 沒(méi)有在導(dǎo)航的地形上, 最關(guān)鍵的是:由此引發(fā)的報(bào)錯(cuò): \\\"SetDestination\\\" can only be called on an active agent that has been placed on a NavMesh. 導(dǎo)致角色無(wú)法移動(dòng)。 我找了很久

    2024年02月13日
    瀏覽(28)
  • 解決npm run build 打包出現(xiàn)XXXX.js as it exceeds the max of 500KB.

    問(wèn)題描述: npm run build 時(shí)出現(xiàn)下面的問(wèn)題: 在項(xiàng)目的根目錄加粗樣式下找到 .babelrc 文件或者babel.config.js文件,增加 “compact”: false ,如: 如果不存在則手動(dòng)創(chuàng)建該文件,并填寫(xiě)內(nèi)容如:

    2024年02月09日
    瀏覽(21)
  • cannot be resolved to absolute file path because it does not reside in the file system 問(wèn)題解決

    cannot be resolved to absolute file path because it does not reside in the file system 問(wèn)題解決

    在Springboot中利用Resource來(lái)獲取文件并在前端返回該文件, 本地測(cè)試正常, 打包到遠(yuǎn)程報(bào)錯(cuò): cannot be resolved to absolute file path because it does not reside in the file system 緊接上一個(gè)問(wèn)題: 項(xiàng)目打包成 jar 后包無(wú)法讀取src/main/resources下文件, 在Springboot打包之后, 無(wú)法讀取到j(luò)ar包內(nèi)的文件, 因此

    2023年04月18日
    瀏覽(32)
  • Did not attempt to load JSON data because the request Content-Type was not ‘a(chǎn)pplication/json‘

    在使用flask-restfull進(jìn)行API開(kāi)發(fā)的時(shí)候。一旦我使用類似下面的代碼從url或者form中獲得參數(shù)就會(huì)出現(xiàn)報(bào)錯(cuò):Did not attempt to load JSON data because the request Content-Type was not ‘a(chǎn)pplication/json’。 代碼如下: 解決方法如下

    2024年02月16日
    瀏覽(26)
  • The operation couldn’t be completed. Unable to launch com.xxx because it has an invalid code signatu

    通過(guò)Xcode跑app到真機(jī)上出現(xiàn)錯(cuò)誤 手機(jī)彈窗提示:“需要互聯(lián)網(wǎng)連接以驗(yàn)證是否信任開(kāi)發(fā)者“xxx”。此App在驗(yàn)證前將不可用” Xcode提示: The operation couldn’t be completed. Unable to launch com.xxx because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by th

    2024年02月12日
    瀏覽(27)
  • [vite] Failed to parse source for import analysis because the content contains invalid JS syntax.

    目錄 在使用vite工具開(kāi)發(fā)Vue.js 3.0項(xiàng)目時(shí),由于配置問(wèn)題,導(dǎo)致了項(xiàng)目運(yùn)行報(bào)錯(cuò),錯(cuò)誤提示如下: 解決步驟,如下: 1、 首先安裝依賴插件 2、接著配置vite項(xiàng)目配置文件:vite.config.js 3、重新運(yùn)行 這個(gè)錯(cuò)誤的大概意思是在解析import的資源路徑時(shí)出錯(cuò)了,因?yàn)閕mport的內(nèi)容不合法

    2024年02月11日
    瀏覽(34)
  • [vite]:報(bào)錯(cuò)Failed to parse source for import analysis because the content contains invalid JS syntax.

    在使用vite工具開(kāi)發(fā)Vue.js 3.0項(xiàng)目時(shí),由于配置問(wèn)題,導(dǎo)致了項(xiàng)目運(yùn)行報(bào)錯(cuò),錯(cuò)誤提示如下: 解決方法 1、 首先安裝依賴插件 2、接著配置vite項(xiàng)目配置文件:vite.config.js 3、重新運(yùn)行 解決!

    2024年02月16日
    瀏覽(27)
  • Refused to execute script from ‘http://localhost:8080/login.html‘

    Refused to execute script from ‘http://localhost:8080/login.html‘

    最近學(xué)習(xí)SpringSecurity,在添加了SpringSecurity依賴后導(dǎo)致原先的網(wǎng)站圖片、js代碼都顯示不出來(lái)了,瀏覽器報(bào)錯(cuò),代碼如下 原因,將靜態(tài)頁(yè)面、JS、img等資源都放在了resource的static文件夾下,導(dǎo)致security默認(rèn)攔截了這些請(qǐng)求,從而訪問(wèn)頁(yè)面時(shí)組件的事件不起作用,控制臺(tái)報(bào)錯(cuò)如下

    2024年02月07日
    瀏覽(14)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包