我在使用React JS和ASP Web API创建应用程序时遇到了问题
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:53248/api/home/saveData. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
我的React组件代码是
submitData(event) {
fetch("http://localhost:53248/api/home/saveData", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
// userName: this.state.userName,
// password: this.state.password,
email: this.state.email
})
}).then((Response) => Response.json())
.then((findresponse) => {
if (findresponse.result == 'authenticated')
alert("1");
else
alert("2");
})
}
此问题的任何帮助。