What are proper status codes for CORS preflight requests?

前端 未结 2 2044
孤独总比滥情好
孤独总比滥情好 2020-11-29 06:56

What status code should a well-written HTTP server return when it gets a CORS preflight (OPTIONS) request?

200, 204 or somethi

2条回答
  •  温柔的废话
    2020-11-29 07:34

    I used 204. Now it's not working cross-browser anymore. Use 200. Firefox started rejecting CORS requests if 204 is received in the preflight. It wasted me almost 2 hours debugging it.

    Lesson to learn: When in doubt about web standards don't choose what makes sense spec wise(i.e. 204 for no content)...choose what most people do(the easy/stupid choice)

提交回复
热议问题