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

后端 未结 6 1797
一个人的身影
一个人的身影 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条回答
  •  梦毁少年i
    2020-12-30 20:38

    Your server needs to reply to the OPTIONS http method. Not only to GET/POST/PUT/DELETE. Safari silently requests this hidden in the background. You can discover this with a MITM-attack on the connection, e.g. Fiddler.

    The OPTIONS request at least needs to respond with the Cross-Origin Resource Sharing (CORS) headers, e.g.:

    • Access-Control-Allow-Headers
    • Access-Control-Allow-Methods
    • Access-Control-Allow-Origin

    Additionally: Your Web Application Firewall (WAF) or Application Security Manager (ASM) needs to allow the OPTIONS request to pass through to your server. Often this is blocked by default, because it gives some slivers of information about the attack surface variables (http methods & headers) used by your API.

提交回复
热议问题