【发布时间】:2015-02-28 11:12:00
【问题描述】:
我正在尝试使用 $http 服务连接到 API,该服务需要为 POST 请求定义特定标头:
app.run(['$http', function($http) {
$http.defaults.headers.post.hello = 'world';
}]);
但是,我的 Angular 应用在 POST 之前发送了一个 OPTIONS 请求,并且它似乎没有发送自定义标头。
查看此 Plunker 中的网络选项卡:http://plnkr.co/edit/tcqIb2q9zIQb3nf2SzyT
请注意,请求应该在哪里发送一个值为world 的hello 标头,但实际上不是:
我在access-control-request-header 中看到hello,但它不应该在自己的行上吗?为什么它不发送值world?
【问题讨论】:
标签: angularjs http-headers cors