Obviously cross-domain, but did not send an options request?

as mentioned above, I obviously made a request to the backend across domains, but I didn"t send an options request in network. What happened?

clipboard.png

Jul.28,2021

you can post the request of your request or the code of ajax to see if it is a simple request
in fact, cross-domain requests are divided into simple cross-domain requests and complex cross-domain requests
simple cross-domain requests do not send options requests
complex cross-domain requests will send a pre-check request options
1. POST Content-Type of the request is not application/x-www-form-urlencoded, Multipart/form-data, or text/plain
3. The request has a custom header field


AJAX cross-domain requests can be divided into two types: simple requests and non-simple requests

simple request:

  • request method is HEAD , GET , POST
  • there is no custom request header in the header of the request
  • Content-Type are as follows: application/x-www-form-urlencoded , multipart/form-data , text/plain , etc.

non-simple request:

  • AJAX requests with custom request headers in header
  • AJAX request in the form of PUT , DELETE
  • The type of
  • Content-Type field is application/json , etc.

when the AJAX makes a non-simple request, the browser will send a pre-check ( OPTIONS ) request, and this pre-check request can set the cache time on the server. That is, a pre-check request will not be sent until the first visit, and a second request within the cache time will not send a pre-check request.

you can see what type of AJAX request you sent.

Change

1.0 to get's request! 2.0 post to set the header field!


you need the backend to open and accept the options request

Menu