javascript - When sending a request, there is often one more request before it is initiated. What are the reasons?
滿天的星座
滿天的星座 2017-05-17 10:03:33
0
4
537

Interfaces are all CORS cross-domain

An extra request: Request Method: OPTIONS, no parameters passed

Extra request response headers

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Allow-Methods:POST, GET, PUT, OPTIONS, DELETE
Access-Control-Allow-Origin:*
Access-Control-Max-Age:3600
Allow:GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Connection:keep-alive
Content-Length:0
Date:Fri, 05 May 2017 09:27:40 GMT
Server:WildFly/10
X-Powered-By:Undertow/1

Response headers for normal requests

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Allow-Methods:POST, GET, PUT, OPTIONS, DELETE
Access-Control-Allow-Origin:*
Access-Control-Max-Age:3600
Connection:keep-alive
Content-Type:application/json;charset=UTF-8
Date:Fri, 05 May 2017 09:27:41 GMT
Server:WildFly/10
Set-Cookie:JSESSIONID=Zv7WiKxKZFNkE6ihLsGfGwYF8ZEFNEFxENl7rNLW.localhost; path=/bridge
Transfer-Encoding:chunked
X-Powered-By:Undertow/1
滿天的星座
滿天的星座

reply all(4)
漂亮男人

Cross-domain post request requires option once

巴扎黑

Correct answer upstairs, if it is a simple cross-domain request, it is recommended not to use POST

曾经蜡笔没有小新

If you curl your request, there should be no such pre-request

PHPzhong

Correct answer on the 1st floor, cross-domain requests will be optioned to the server first. After being verified by the server, the request will be sent

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template