jQuery cross domain POST shenanigans

前端 未结 4 1212
北海茫月
北海茫月 2020-12-09 10:16

I\'m trying to authenticate to an API, which only allows you to authenticate using a POST with JSON as form data, in the format of {\"username\":\"myusername\",\"password\":

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 10:46

    The problem is that the domain you are trying to POST to doesn't respond to the OPTIONS request that is sent before each cross-domain request. With the OPTIONS request, the browser receives information about cross domain rules etc. To enable the cross domain request, the server has to set Access-Control-Allow-Origin:* (or the domain of the script, actually, but * covers everything) and maybe Access-Control-Allow-Methods: GET, POST, OPTIONS headers.

提交回复
热议问题