axios发送OPTIONS请求

因为发送的请求不是simple request,所以浏览器会发送一个OPTIONS请求询问服务器是否可以请求,这样每次请求都会发送两次请求,解决的办法是简化请求。

 

simple request

  1. get、post、head 请求类型
  2. 不要设置列表之外的header(如: user-agent)
  3. Content-Type 只能是:

    • application/x-www-from-urlencoded
    • multipart/from-data
    • text/plain

不设置Content-Type默认的属性是application/json

相关文章:

  • 2023-02-15
  • 2021-07-25
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-02-08
  • 2022-01-13
相关资源
相似解决方案