我收到以下错误:
Access to XMLHttpRequest at 'http://localhost:40000/api/summaryCount/failed-requests' from origin
'http://localhost:3000' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我创建了一个proxy.conf.json文件,其中包含以下内容:
{"/api/*": {
"target": "http://localhost:40000",
"secure": false
}
}
"proxyConfig": "proxy.conf.json"
在“发球”上:{“选项”{。。。。。。
最后,我修改了package.json,使“start”选项变成:
"start": "ng serve
在创建HttpHeaders对象时,如果添加以下内容:
httpHeaders = new HttpHeaders().append('Access-Control-Allow-Origin', 'http://localhost:3000').....
这仍然没有区别。
有人能告诉我我错过了什么吗。