collectiveintel/cif-v1 — pull request #76 by shatlovsky (2014-07-21 09:30:47+00:00)
Title: AJAX: Support Chrome's preflight OPTIONS request to look for CORS headers

Hi

I've added support to OPTIONS request in JSON module. It is required by Chrome which is doing preflight request before actual AJAX call to check CORS headers. It happens in a situation when a web app using CIF API and the CIF backend itself are located on different hosts.

It also makes sense to configure Apache to add CORS headers to each
response:

SetEnvIf Origin "^https?://(your-web-app)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
Header always set Access-Control-Allow-Headers "x-requested-with"