最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - (CORS) How does the browser know when to do a pre-flight request - Stack Overflow

programmeradmin0浏览0评论

So I have been using CORS for a short time now, I just read up on how it works behind the scenes.

My question is how does the browser know when to do a pre-flight request?

There is no issue involved right now, as the browser seems to be working fine, I am just a little bit curious. Because when I make the request, I am not giving it any information on whether or not it is CORS, yet it still knows to do a pre-flight.

So I have been using CORS for a short time now, I just read up on how it works behind the scenes.

My question is how does the browser know when to do a pre-flight request?

There is no issue involved right now, as the browser seems to be working fine, I am just a little bit curious. Because when I make the request, I am not giving it any information on whether or not it is CORS, yet it still knows to do a pre-flight.

Share Improve this question asked Jun 17, 2015 at 17:12 Qasim AhmedQasim Ahmed 1972 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

The browser will send a preflight request if:

  • You add custom headers to your request
  • You use a method other than GET, HEAD or POST
  • You use POST with an unusual Content-Type.

More details here: HTTP access control (CORS), Preflighted requests

发布评论

评论列表(0)

  1. 暂无评论