Restangular 阻止 'preflight' OPTIONS 调用

Restangular prevent 'preflight' OPTIONS call

我正在尝试找出如何防止在对我们的 API 服务器的每次 GET 调用时触发 OPTIONS 调用。

我正在尝试这个:

.config(function(RestangularProvider) {
    RestangularProvider.setDefaultHeaders({"X-Requested-With" :"", "Content-Type": "text/plain"});
})

但这对我没有任何好处。一切仍然认为它是 application/json 所以它触发预检调用。有什么我可以做的吗?

看看这个:

OPTIONS requests are what we call pre-flight requests in Cross-origin resource sharing (CORS).

They are necessary when you're making requests across different origins.

This pre-flight request is made by some browsers as a safety measure to ensure that the request being done is trusted by the server. Meaning the server understands that the method, origin and headers being sent on the request are safe to act upon.

Your server should not ignore but handle these requests whenever you're attempting to do cross origin requests.