1

I'm trying to figure out how to prevent the OPTIONS call from firing on every GET call to our API server.

I'm trying this right now:

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

But it's not doing me any good. Everything still thinks it's application/json so it fires off the preflight call. Is there anything I can do?

m0ngr31
  • 671
  • 9
  • 26

1 Answers1

3

Check this out:

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.

How to disable OPTIONS request?

Community
  • 1
  • 1
Nemanja Milosavljevic
  • 1,056
  • 12
  • 31