html 拒绝加载脚本“https://apis.google.com/js/api.js?onload=__iframefcb566635”

mfpqipee  于 2023-02-27  发布在  Go
关注(0)|答案(1)|浏览(268)

我尝试与API“www.example.com“建立连接https://brasilapi.com.br/api/ibge/uf/v1,但收到以下错误:

chunk-OMODUTDX.js:79 Refused to load the script 'https://apis.google.com/js/api.js?onload=__iframefcb559688' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

这是我的HTML头:

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/css/style.css">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
<script src="https://kit.fontawesome.com/d4c0dbaccd.js" crossorigin="anonymous"></script>

这是我的js代码:

async function carregarEstados(){
    const APIResponse = await fetch(`https://brasilapi.com.br/api/ibge/uf/v1
    `)
    if(APIResponse.status === 200){
        const data = await APIResponse.json()
        console.log(data[1]['sigla'])
        for (let index = 1; index <= data.length; index++) {
            const doc = `
           <option value=${data[index]['sigla']}>${data[index]['sigla']}</option>
           `
           document.querySelector('#estado').append(doc)  
        }
    }else{
        console.log("Algo deu errado")
    }
}
gkn4icbw

gkn4icbw1#

正在为您的网站设置内容安全策略,可能在响应标头中。您需要标识设置此CSP的位置并对其进行修改。它可以在代码中设置,但默认情况下更可能在框架中、Web服务器或代理上设置。

相关问题