我正在从本地服务器发出请求,并且:
{ _40: 0 _55: null _65: 0 _72: null }
开发者控制台会向我提供此反馈:
跨域请求被阻止:“同源起源”策略禁止读取https://theurlthatiwanttoget.herokuapp.com/something处的远程资源。 (原因:CORS请求未成功。)
我的请求:
await axios.get('https://theurlthatiwanttoget.herokuapp.com/something', {
headers: {"Access-Control-Allow-Origin": "*"}
});
我的问题是:我可以从客户端做些什么,还是可以确定问题出在服务器上吗?
答案 0 :(得分:0)
您可以创建proxy.conf.json文件
包含
{
"/api": {
"target": "http://your address/",
"secure": true,
"changeOrigin": true
}
}
并运行
通过--proxy-config proxy.conf.json提供服务命令