Http-Method changes from POST to OPTIONS when changing Content-Type

时间秒杀一切 提交于 2019-11-30 22:15:53
Achal Dave

When you add a header to an XHR object, most browsers will do a preflight request, which is the OPTIONS method that you are seeing. There is not a way to circumvent this if you are adding custom headers, unfortunately. The POST will be sent after the OPTIONS.

This article explains the OPTIONS request a bit. I ran into issues with the preflight a while back, if that is any help.

If you have specific issues with the OPTIONS request you should edit your question to include them; otherwise, this is expected behavior.

FWIW mine also failed to update the type when I specified...

{'content-type':'application/json'}

However, if I corrected the case to

{'Content-Type':'application/json'}

... it worked.

Go figure.

If you are pass Content-Type on authorization request it will convert POST method to OPTIONS method so while we are use ouath and passing authorization token that time do not required Content-Type.

So do not pass Content-Type on all authorization request it won't change your method POST to OPTIONS

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!