Search code examples
ajaxsuperagent

How do I prevent SuperAgent AJAX from calling OPTIONS?


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


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.