Security

SplunkJS SDK: Getting error "Request header field X-Splunk-Form-Key is not allowed by Access-Control-Allow-Headers" after migrating to 6.5.x

mgarciar
Path Finder

Hi all,

I have a custom web page calling Splunk services using SplunkJS SDK. After migrating to 6.5, the page started failing with this message:

XMLHttpRequest cannot load https://(hostname):(port)/services/auth/login?output_mode=json. Request header field X-Splunk-Form-Key is not allowed by Access-Control-Allow-Headers. 

The code is the following:

function getJSONConnectionParams(username,password,hostname){
     return JSON.parse('{"username":"'+username+'","password":"'+password+'","scheme":"https","host":"'+hostname+'","port":8089}');
}

var http = new splunkjs.JQueryHttp();
var service = new splunkjs.Service(http,getJSONConnectionParams(splunkCurrentUser,currentPassword,getHostName()));

service.login(function(err) { ... }

The error shows up when the login function is called.

Splunk Web UI and Management port are using HTTPS, both certificates are the same. Also the crossOriginReference is enabled on the server.conf file.

Any help will be appreciated.

Thanks and regards,

0 Karma
1 Solution

mgarciar
Path Finder

Looking at the splunkjs code I found the "SplunkWebHttp" which seems to be using the standard " /splunkd/__raw" path.
Replacing the line:

var http = new splunkjs.JQueryHttp();

with

var http = new splunkjs.SplunkWebHttp();

Solved the issue.

I couldn't find any documentation about this. Seems all samples assume you want to use a proxy server.

View solution in original post

0 Karma

mgarciar
Path Finder

Looking at the splunkjs code I found the "SplunkWebHttp" which seems to be using the standard " /splunkd/__raw" path.
Replacing the line:

var http = new splunkjs.JQueryHttp();

with

var http = new splunkjs.SplunkWebHttp();

Solved the issue.

I couldn't find any documentation about this. Seems all samples assume you want to use a proxy server.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...