Safari

时间:2017-10-31 23:39:48

标签: browser cors axios

我正在使用Axios Javascript库发送CORS AJAX请求,但似乎Safari正在重定向上发送空请求正文,而不是实际正文(Chrome和Firefox正确发送)。

这里的问题是什么?这是一个Safari bug吗?也许是Axios的错误?或者我发送错误请求?

这是HTTP流。

POST /session/login HTTP/1.1
Host: api.test.co.uk
Content-Type: application/x-www-form-urlencoded
Origin: http://test.co.uk
Accept-Language: en-gb
Accept-Encoding: br, gzip, deflate
Connection: keep-alive
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38
Referer: http://test.co.uk/login
DNT: 1
Content-Length: 56

grant_type=password&username=foo&password=bar

HTTP/1.1 307 Temporary Redirect
Server: nginx/1.12.1
Date: Tue, 31 Oct 2017 18:37:10 GMT
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: DELETE, GET, OPTIONS, POST, PUT
Access-Control-Allow-Headers: Accept, Accept-Language, Authorization, Content-Language, Content-Length, Content-Type, Origin, Range, X-Requested-With
Access-Control-Expose-Headers: Origin, Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers
Location: /token

POST /token HTTP/1.1
Host: api.test.co.uk
Content-Type: application/x-www-form-urlencoded
Origin: http://test.co.uk
Accept-Encoding: br, gzip, deflate
Content-Length: 0
Connection: keep-alive
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38
Referer: http://test.co.uk/login
DNT: 1
Accept-Language: en-gb

HTTP/1.1 400 Bad Request
Server: nginx/1.12.1
Date: Tue, 31 Oct 2017 18:37:10 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 34
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: DELETE, GET, OPTIONS, POST, PUT
Access-Control-Allow-Headers: Accept, Accept-Language, Authorization, Content-Language, Content-Length, Content-Type, Origin, Range, X-Requested-With
Access-Control-Expose-Headers: Origin, Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers
Cache-Control: no-cache
Pragma: no-cache
Expires: -1

{"error":"unsupported_grant_type"}

0 个答案:

没有答案