I am trying to write data to Splunk with a jQuery script running in a browser. I already have the following in my 'inputs.conf' file:
crossOriginSharingPolicy = *
However, the error I'm getting is:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myserver.myco.com:8088/services/collector/event.
(Reason: missing token 'content-type' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).
I have not found a way to set the 'Access-Control-Allow-Headers' from Splunk.
Here is a snippet of the JS code, although I'm not sure it is even necessary to show it (the commented lines are things I tried in desperation, but they made no difference):
var dfr = $.ajax({
url: config.endpoint,
method: 'post',
// headers: {
// "Access-Control-Allow-Origin" : "*",
// "Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS",
// "Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
// },
// crossDomain: true,
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", header);
},
data: JSON.stringify({ event: post }),
contentType: "application/json; charset=utf-8",
dataType: "json"
});
Any suggestions? Do I need to access Splunk via a proxy?