Deployment Architecture

Request to port 8089 from 8000

thibault28
Engager

From my Splunk app, I am running into a cross origin error when I try to request the port 8089 from the port 8000

Here is the error:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.

I tried to configure server.conf setting crossOriginSharingPolicy = "http://localhost:8000"

But it doesn't seem to work so far. If I use a chrome CORS plugin it works fine though.

Any idea?

Thanks

marcolesh
Path Finder

In order to get it done, you have to configure server.conf setting crossOriginSharingPolicy = http://localhost:8000 change to match yours. Following code was fine to me in the JS.

But if you are trying to consume the webservice from SplunkWeb to Splunkd, I strongly recommend you to expose the endpoint in your web.conf and the acces it through localhost:8000/en-US/splunkd/__raw/services/custom_service in order to avoid CORS headers problems.

For web.conf

[expose:echo_persistent]
methods = POST
pattern = echo_persistent

This code was fine to me

var text = $("#text").val();
            var xhr = new XMLHttpRequest();
             xhr.open('POST', '/en-US/splunkd/__raw/services/custom_service', true);
             xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
             xhr.setRequestHeader('X-Splunk-Form-Key', document.cookie.match(/splunkweb_csrf_token_8000=(\d+)/)[1]); 
             xhr.send(text);

You can search for splunk_rest_examples for further information.

0 Karma

marcolesh
Path Finder

Hi, did you find the solution?

0 Karma

fabiocaldas
Contributor

Use a general approach like "*" as demonstrated at http://dev.splunk.com/view/webframework-developapps/SP-CAAAEW6

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...