每当我以角度运行代码时,都会收到此错误:
CORS策略已阻止从来源“ https://drive.google.com/file/d/1Fb6Oq_7OABkuYUwIbcSiU2hEXtKHWuVE/view?usp=sharing”访问“ http://localhost:4200”处的XMLHttpRequest:请求的资源上没有“ Access-Control-Allow-Origin”标头。
HttpErrorResponse {
headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "https://drive.google.com/file/d/1Fb6Oq_7OABkuYUwIbcSiU2hEXtKHWuVE/view?usp=sharing", ok: false```
}
我尝试使用proxy.config.json对其进行修复:
{
"/api": {
"target": "http://localhost:3000",
"secure": "false",
"changeOrigin": true,
"logLevel": "debug"
}
}
在angular.json中,我添加了服务和配置:
"proxyConfig": "proxy.config.json"
当我运行ng serve
时,我收到消息:
[HPM] Proxy created: /api -> http://localhost:3000
[HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
并且它运行。
但这似乎无法解决问题。如何修复我的代码,使其不会阻止与我尝试连接的Google电子表格的连接?