首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Angular中解析远程资源

在Angular中解析远程资源
EN

Stack Overflow用户
提问于 2018-07-29 00:47:53
回答 1查看 84关注 0票数 -3

在Angular 5中,当通过 http.get()**?**访问远程资源时,关于CORS,我需要考虑什么

示例:

代码语言:javascript
复制
let url = `http://www.google.com`;
this.http.get(url).subscribe(res => {
    console.log(res.text());
    // parse html
});

结果:

代码语言:javascript
复制
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 

使用Angular和Firebase生态系统,有没有推荐的方法来解决这个问题?例如,我可以使用云函数通过Node.js访问远程url吗?开发人员通常是如何解决这个问题的?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51573357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档