什么情况下会发送 OPTIONS 请求
Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 363
Author 回答者: nextprops
搬运地址 1:请求的方法不是GET/HEAD/POST 2:POST请求的Content-Type 异常 3:请求设置了自定义的header字段
Author 回答者: shfshanyue
当一个请求跨域且不是简单请求时就会发送 OPTIONS 请求
满足以下条件就是一个简单请求:
Method: 请求的方法是GET、POST及HEADHeader: 请求头是Content-Type、Accept-Language、Content-Language等Content-Type: 请求类型是application/x-www-form-urlencoded、multipart/form-data或text/plain
而在项目中常见的 Content-Type: application/json 及 Authorization: <token> 为典型的非简单请求,在发送请求时往往会带上 Options
更详细内容请参考 CORS - MDN