AJAX获得与CORS定制响应头AJAX、CORS

2023-09-11 22:32:35 作者:夢遺,才想起妳

我的服务器发送自定义的报头以及响应。我得到的响应数据好了,但我不能用jQuery的 getAllResponseHeaders()访问自定义标题或AngularJS $ HTTP 服务。我得到的是内容类型。当我检查与DevTools或小提琴手请求响应,我可以看到被送到服务器所有自定义标题,但我不能从XHR得到他们。有什么办法来访问所有的头?

My server sends custom headers along with the response. I get the response data alright, but I can't access the custom headers with jQuery's getAllResponseHeaders() or AngularJS $http service. All I get is content-type. When I inspect the request response with DevTools or fiddler, I can see all the custom headers being sent by the server, but I can't get them from xhr. Is there any way to access all the headers?

推荐答案

确定我得到这个工作在我的服务器配置加入让头后访问控制 - 揭露-头

OK I got this working after adding allowed headers in my server config Access-Control-Expose-Headers