Http Option Method with Javascript request

风流意气都作罢 提交于 2019-12-07 00:06:11

问题


I use backbone.js' s model. When i save the model, it sends HTTP OPTIONS method to server-side on firefox, but sends HTTP POST method with safari.

I know it is not an issue about backbone.js, it is about CORS. I will just check if method, GET, POST, PUT and DELETE on server-side, i will not do a job with HTTP OPTIONS method.

my requested url is my api: api.foo.com and api requested from: bar.com

so, how can i control in all browsers request my api.foo.com with HTTP POST not OPTIONS? and how can i share api.foo.com' s content with all request from any other domains?

Note: i have already changed response' s headers from server-side to: Access-Control-Allow-Origin: *


回答1:


The OPTIONS request is actually the so called preflight request of the CORS specification. This preflight request is used by web browsers to check under what conditions the server would accept a request from the respective origin. If the response to the preflight request was satisfying, the browser will send the actual request.

So to comply with this specification, you need your server to reproduce the steps of preflight request processing.



来源:https://stackoverflow.com/questions/8342420/http-option-method-with-javascript-request

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