在Angular5中,当通过
http.get()
?
例子:
let url = `http://www.google.com`;
this.http.get(url).subscribe(res => {
console.log(res.text());
// parse html
});
结果:
Failed to load https://www.google.com/:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access.
core.js:1350 ERROR
使用角和火碱生态系统,有没有建议的方法来解决这个问题?例如,可以使用云函数通过node.js访问远程URL吗?开发人员通常如何解决这个问题?