Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top