服务器响应204后Chrome不发送主要请求

时间:2017-03-20 08:26:57

标签: google-chrome cors preflight

CORS Pre-flight request response flow

继承人我的nginx conf:

   add_header 'Access-Control-Allow-Origin' '*';
   add_header 'Access-Control-Allow-Methods' '*';
   add_header 'Access-Control-Max-Age' 1728000;
   add_header 'Access-Control-Allow-Credentials' 'true';
   add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization,Lang';
   add_header 'Content-Length' 0;
   add_header 'Content-Type' 'text/plain charset=UTF-8';
   return 204;

Chrome收到了来自nginx的204回复,但它没有发送主请求应该是。

我在firefox中测试了相同的请求,而不是chrome,这很好。

感谢您的帮助。

enter image description here

PS:nginx日志: 来自chrome的请求:

192.168.10.172 - - [20/Mar/2017:15:32:40 +0800] "OPTIONS /api/1.0/workflow/project/53469591758c77e464b9504040842886/process-variable/jtxmmc_select/execute-query HTTP/1.1" 204 0 "https://wf.sxvtc.com/sysworkflow/zh/neoclassic/cases/cases_Step?TYPE=DYNAFORM&UID=85519901758c8db854092e8090509883&POSITION=2&ACTION=EDIT" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36" "-"

来自Firefox的请求:

192.168.10.172 - - [20/Mar/2017:15:32:02 +0800] "POST /api/1.0/workflow/project/53469591758c77e464b9504040842886/process-variable/jtxmmc_select/execute-query HTTP/1.1" 200 2594 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0" "-"

我不明白为什么chrome发送选项方法和firefox没有!

0 个答案:

没有答案