Although I have come across many similar questions, none of them have helped me solve my specific problem.
jQuery.post( 'http://example.com/api_offer/get_time_left', function(data) {
console.log('get time');
}, 'json');
When I check the Chrome console, I see this error message:
XMLHttpRequest cannot load http://example.com/api_offer/get_time_left. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[my local domain]' is therefore not allowed access.
In the nginx site configuration, I have the following settings:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 300;
add_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Origin $http_origin;
}
I am using Vagrant, but the same error occurs when I try to run it on a Unix server, not just on my localhost. I have checked the error logs for nginx and the domain site, but haven't found anything useful.
Why is it not working even though I have set * to allow any domain? What other options do I have to resolve this issue?