我正在编写一个 Angular 应用程序,它通过 $http 服务向AppVeyor REST API发出 GET 请求,以获取我的项目的最后构建状态,但我收到了 CORS 错误。
当我从Fiddler尝试时,它可以工作。
var buildStatus= 'https://ci.appveyor.com/api/projects/accountName/projectSlug';
var token = 'q3245dsfg'; // my account api token
$http.get(buildStatus, {
headers: {
'Authorization': 'Bearer ' + token
}
}).then(...
这是我在 Firefox 上遇到的错误:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ci.appveyor.com/api/projects/accountName/projectSlug. (Reason: CORS request failed).
有任何想法吗?