5

I found the source of my problem for SuperAgent (http://visionmedia.github.com/superagent/) on Firefox. Not sure if SuperAgent is doing it in its AJAX call or if FireFox is triggering it.

Essentially, every time I make an AJAX call an OPTIONS method is being fired on the URL before the actual AJAX call. Quite annoying since the server currently doesn't support OPTIONS. How can I make a call without it going to crap and re-coding the server?

Thanks

crockpotveggies
  • 11,654
  • 11
  • 65
  • 127

2 Answers2

5

Ok found out some more details. Thankfully testing on Safari gave me more insight into what was actually happening and I applied my knowledge here.

It seems to be the standard that browsers are calling an OPTIONS method before making an actual AJAX call. Seems a bit overbearing.

So to get around it I simply added a catch-all in my reverse proxy server to handle each OPTIONS call. You can see the question below for the code:

Play! 2.0 easy fix to OPTIONS response for router catch-all?

And if you want to read up more on why browsers are doing this, see here:

Why am I getting an OPTIONS request instead of a GET request?

OPTIONS is from the CORS standard.

Community
  • 1
  • 1
crockpotveggies
  • 11,654
  • 11
  • 65
  • 127
0

Disabling web-secuty in phantomjs also helped to resolve this problem (--web-security=no). Because I didn't have access to API server to make changes for OPTION method.

Serge
  • 1,629
  • 1
  • 25
  • 41