jQuery AJAX fails to work (OPTIONS pre-flight request made) when headers are specified

前端 未结 1 1243
醉话见心
醉话见心 2020-12-06 02:27

The AJAX request works fine, but the moment I add a header via beforeSend or headers, an OPTIONS pre-flight request is made and the GET request is aborted.

         


        
相关标签:
1条回答
  • 2020-12-06 02:48

    Solved. Thanks @JasonP for pointers. Changed Server Response Headers from

    Access-Control-Allow-Headers:*

    to specific ones

    Access-Control-Allow-Headers: Content-Type, Accept, X-Requested-With, Session

    and now it works!

    0 讨论(0)
提交回复
热议问题