We have Nginx as a proxy with this header.
nginx::server: |
expires modified +5m;
large_client_header_buffers 4 32k;
add_header Access-Control-Allow-Origin *;
That's the configuration from puppet so I assume that it should work for any domain. I try with cURL which I get the response correct as.
* upload completely sent off: 406 out of 406 bytes
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< cache-control: max-age=300
< Content-Type: application/json; charset=utf-8
< Date: Mon, 08 Feb 2016 16:52:15 GMT
< Expires: Mon, 08 Feb 2016 16:57:15 GMT
< Content-Length: 542
< Connection: keep-alive
However, when I try with jQuery post I get CORS error.
jQuery.ajax('theURL', {
contentType: 'application/json',
method: 'POST',
data: JSON.stringify({'json'}),
dataType: 'json',
crossDomain: true
})
The application is Hapi.js which is really simple as this.
var server = new Hapi.Server();
server.connection({ port: config.port });
Not sure if I'm missing anything?