Hello,

This is a little bit off topic, but I am hoping some one here can help.

It appears that the jquery code for acts_as_list does something that causes it to do a OPTIONS before it does a POST to the reorder method in the controller. It shows up in nginx logs as:

   199.21.150.18 - - [03/Aug/2012:14:18:12 -0400] "OPTIONS
   /requests/requests/reorder HTTP/1.1" 301 184 "-" "Mozilla/5.0 (X11;
   Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko)
   Chrome/21.0.1180.55 Safari/537.1"

According to the Nginx and HTTP OPTIONS method <http://blog.rogeriopvl.com/archives/nginx-and-the-http-options-method/> blog, OPTIONS is "essential if you're doing cross-site HTTP requests and need to obtain the server authorization for the URI where the request originated from". It turns out that this method is not directly supported in nginx, but you can implement using the extraheaders module and the article gives an example on how to do it. I altered the example to what I thought would work in my situation as follows:

      location /requests/requests/reorder {
        if ($request_method = OPTIONS ) {
            add_header Access-Control-Allow-Origin
   "https://projects.instantiated.ca/*";;    # I also tried without the "/*"
            add_header Access-Control-Allow-Methods "GET, OPTIONS";
            add_header Access-Control-Allow-Headers "Authorization";
            add_header Access-Control-Allow-Credentials "true";
            add_header Content-Length 0;
            add_header Content-Type text/plain;
            return 200;
        }
        if ($request_method = 'POST') {
            more_set_headers 'Access-Control-Allow-Origin: *';
            proxy_pass http://requests_production_upstream;
        }
   }

Note that I don't think I can use a location of "/" as was done in the blog because I have other (non-Hobo) applications running on the server.

If anybody has any ideas or insights, that would be greatly appreciated. Alternatively, if anyone knows how to turn off the generation of the OPTIONS method call, that equally would be appreciated.

Cheers,
Henry

--
Henry Baragar
Instantiated Software
www.instantiated.ca

<<attachment: Henry_Baragar.vcf>>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to