CORS Toggle 浏览器跨域访问问题的解决

2018-05-15  本文已影响72人  哪种生活可以永远很轻松

一、问题

代码中通过url请求了来自服务器的数据:

return this.http.get(this.heroesUrl);

浏览器console报错:

Failed to load http://www.u0626.xyz/fileserver/heroes.json: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:4200' is therefore not allowed access.

HttpErrorResponse
"Http failure response for (unknown url): 0 Unknown Error"

二、跨域访问

访问非本域名下的资源

三、解决方案

google chrome 插件 CORS Toggle

上一篇 下一篇

猜你喜欢

热点阅读