Dependencies and cross-domain communication

When running in a web browser, the SDK's only dependency is JSON support. If your site supports older browsers, you might need to include JSON handling for compatibility. To learn more, see the JSON website.

Due to Same Origin Policy (SOP) browser security policies, cross-domain messaging is not possible when you use the file:// protocol, so you must serve the HTML pages from a server.

For running the SDK browser examples, the SDK includes a simple server that requires Node.js (to see the implementation, refer to the /splunk-sdk-javascript/bin/cli.js file). To start the server, enter:

node sdkdo runserver

You can also use this simple server for development. But for production, you could use a proxy on your web server to forward requests to Splunk:

var http = new splunkjs.ProxyHttp( "/proxy" );

Because Splunk is probably not running on your web server, you'll also need to configure your web server to handle these proxy requests and delegate them to your Splunk's host and management port.

For example, on an Apache web server, you could add these two lines to the httpd.conf file:

SSLProxyEngine On
ProxyPass   /proxy/             https://localhost:8089/