After sending a pre-request, the mobile phone cannot automatically initiate a second request for get or post.

the server can only receive the first pre-request (options)
cannot receive the second get or post request

clipboard.png

this is the CORS processing code

No problem on PC

Mar.11,2021

make sure that the request has been sent but has not been received by the backend;
or no request has been made at all.

  1. if a request has been generated, print $_ GET or $_ POST directly on the first line of the method body to see if there is any data
  2. if no request is generated, check the foreground js code

is your client's request initiated through https?
if yes, Acess-Control-Allow-Origin cannot be set to *. You try to use the following configuration:

if(isset($_SERVER['HTTP_ORIGIN'])){
    header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);
}
header('Access-Control-Allow-Credentials:true');
if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
    header('Content-Length:0');
    header('Content-Type:text/plain');
    header('Access-Control-Max-Age:86400');
    header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, Authorization');
    exit;
}

may also be a cache problem

Menu