Dashboards & Visualizations

How to use CORS to allow Javascript to make API calls to a Splunk server?

jstrayer
Engager

We are going to have an application server and Splunk server in different domains (and behind different firewalls). I would like to use CORS to allow Javascript running on a client loaded from our application server to make API calls to a Splunk server.

Every example I've been able to find uses code like this to initialize the Splunkjs API:

var http = new splunkjs.ProxyHttp("/proxy");
var service = new splunkjs.Service(http,{more parameters here});   

I have not been able to figure out what to use instead of splunkjs.ProxyHttp.

My questions are:
1. Is there any example code out there that uses CORS to call the Splunk API (Javascript or not)?
2. What kind of object should I pass to the Service constructor when using CORS?

0 Karma
1 Solution

jstrayer
Engager

The first question is still unanswered, but the answer to the second question is:
var http = new splunkjs.JQueryHttp();

I've tested it and it works.

View solution in original post

0 Karma

krunoslav
Engager

Hello, any updates for newer browsers? I'm trying to run this in 2020 and Firefox is killing all my efforts because of CORS.

0 Karma

msaibi
Engager

Any answer about the CORS issue?

jstrayer
Engager

The first question is still unanswered, but the answer to the second question is:
var http = new splunkjs.JQueryHttp();

I've tested it and it works.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...