【发布时间】:2016-08-21 04:59:09
【问题描述】:
为什么我可以从浏览器/Postman/甚至 Node.js(http.get 方法)发出 REST API 请求,但不能从 Angular 资源发出?
错误信息的sn-p是:
XMLHttpRequest cannot load http://example-of-external-api-site.com
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost' is therefore not allowed access.
在问这个之前,我试着看一下 CORS 的定义。根据我的理解,我可以理解为什么它不允许我从 Angular 的资源发出的请求,因为它来自不同的域。但是,我的浏览器/Postman/Node.js 应用程序不是也来自不同的域吗?
请帮我回答这个问题,我真的不明白为什么..
【问题讨论】: