Reputation: 661
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.
Upvotes: 0
Views: 7605
Reputation: 57
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;
Upvotes: 3