Safari 10.1: XMLHttpRequest with query parameters cannot load due to access control checks

后端 未结 6 1811
一个人的身影
一个人的身影 2020-12-30 20:36

When trying a CORS request on Safari 10.1, on an URL which includes query parameters (e.g. https://example.com/api?v=1), Safari says

6条回答
  •  长情又很酷
    2020-12-30 20:51

    The problem is because it is necessary to be more specific in the data of the cors this does not happen in the other operating systems that do interpret it

    This one worked for me for a back in php

    header ("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
    header ("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
    header ("Allow: GET, POST, OPTIONS, PUT, DELETE");
    $ method = $ _SERVER ['REQUEST_METHOD'];
    if ($ method == "OPTIONS") {
         die ();
    }
    

提交回复
热议问题