iphone request program reported network error

created at 08-10-2021 views: 2

Recently, some users reported that when using the APP, they kept prompting a network error error, but the network itself was normal. At first I thought it was operator hijacking, because I encountered this situation several years ago. The original solution was to configure multiple server domain names into the APP. When you can't connect to the server but you can ping Baidu, you can request another domain name that can be pinged.

It is normal for users to access the server this time, and the three users reported are all Apple phones. Then I checked it. It is found that the ios 12 system does not support the following cross-domain configuration, otherwise it will cause Network error.

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' '*';
if ($request_method = 'OPTIONS') {
    return 200;

Just change it to the following configuration later.

location / {
   #The following is a new configuration
   # Cache of preflight commands, if not cached, two requests will be sent each time
   add_header Access-Control-Max-Age 3600;
   # Requests with cookies need to add this field and set it to true
   add_header Access-Control-Allow-Credentials true;
   # Indicates that this domain cross-domain call is allowed (the domain name and port the client sends the request)
   # $http_origin dynamically obtain the domain requested by the requesting client. The reason for not using * is that requests with cookies do not support *
   add_header Access-Control-Allow-Origin $http_origin;
  # Request method* means all support
   # Indicates the field of the request header is dynamically obtained
   add_header Access-Control-Allow-Headers $http_access_control_request_headers;
   # OPTIONS pre-inspection command, the request is sent only when the pre-inspection command is passed
   # Check if the type of request is a preflight command
   if ($request_method = OPTIONS){
       return 200;
   #Other configuration....

created at:08-10-2021
edited at: 08-10-2021: