代码之家  ›  专栏  ›  技术社区  ›  Ben

以角度分析远程资源

  •  -3
  • Ben  · 技术社区  · 6 年前

    在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吗?开发人员通常如何解决这个问题?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Ritwick Dey    6 年前