收到错误“;拒绝加载映像';http://localhost:3001/favicon.ico'&引用;当使用javascript加载另一个html时?
我正在用html/css/javascript(React,Node.js)制作一个MERN stack web,现在正在尝试实现登录功能。 身份验证工作正常,但是当javascript加载另一个html文件时,我收到一个错误,它说找不到favorite.ico文件 以下是App.js中的代码:收到错误“;拒绝加载映像';http://localhost:3001/favicon.ico'&引用;当使用javascript加载另一个html时?,javascript,html,node.js,reactjs,Javascript,Html,Node.js,Reactjs,我正在用html/css/javascript(React,Node.js)制作一个MERN stack web,现在正在尝试实现登录功能。 身份验证工作正常,但是当javascript加载另一个html文件时,我收到一个错误,它说找不到favorite.ico文件 以下是App.js中的代码: getDataFromDb = (userName, password) => { let validOrNot = false; fetch('http://localhost:3001
getDataFromDb = (userName, password) => {
let validOrNot = false;
fetch('http://localhost:3001/api/getData')
.then((data) =>
data.json()
)
.then((res) => {
this.setState({
data: res.data
})
this.state.data.forEach(function(item) {
if (item.userName === userName && item.password === password) {
console.log('item.username: ' + item.userName + ', username:' + userName)
console.log('item.pass:' + item.password + ', pass: ' + password)
validOrNot = true
}
})
this.setState({
goToMainPage: validOrNot
})
console.log(this.state.goToMainPage)
if (this.state.goToMainPage) {
this.setState({
goToMainPage: false
})
console.log('LogIn function running, now goToMainPage has been false');
window.location.href = 'http://localhost:3001/i.html'
}
})
};
以下是应加载的i.html的一部分:
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
</head>
反应应用程序
下面是错误消息:
拒绝加载映像“”,因为
它违反了以下内容安全策略指令:
“默认src‘无’”。请注意,没有显式设置“img src”,因此
“默认src”用作回退
你解决过这个问题吗?兄弟,发生了什么事?你找到解决办法了吗?