0

This is the error I see in my chrome console.

XMLHttpRequest can not load {URL}. Origin {URL} is not allowed by Access-Control-Allow-Origin.

I've tried to configure my NGINX for CORS:

location / {
    if ($http_origin) {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods "GET,POST,OPTIONS";
    }

But that doesn't seem to help.

The jquery call looks like this:

var submissionData = '{"tweet_id":"'+tweet_id+'", "question_id":"'+question_id+'", '+choiceString+', "extra_passback":"'+extra_passback+'"}';
$.post("http://ec2[...].amazonaws.com/question/answer/", submissionData, function(data) {console.log("success");});

I'm not even sure if the problem is with jquery or nginx.

Khandelwal
  • 661
  • 2
  • 14
  • 24
  • you must be look at [link](http://bionicspirit.com/blog/2011/03/24/cross-domain-requests.html), ah do you have crossdomain.xml in your root dir? – Vahid Chakoshy Apr 28 '12 at 22:08

1 Answers1

3

Based on this post, I added two more headers (in addition to the two you have mentioned in your question above) and it works for me, with JQuery json cross-domain request:

add_header         Access-Control-Allow-Headers   Content-Type;
add_header         Access-Control-Max-Age         86400;
Community
  • 1
  • 1
Nomad Siv
  • 57
  • 4