Dashboards & Visualizations

How do I create an app with a Splunk setup page that has additional dependencies?

christoffertoft
Communicator

I'm trying to create an app with a setup page, and I'm having issues including two separate JS files that are located under the appserver/static/js folder in the app.

I haven't been able to add additional JS files apart from the setup_page.js.

In the setup_page.js, I have included the files as requireJS demands:

require.options( {
    paths: {
         myapp: "../app/myapp/js/"
       }
  });

then:

require([jquery, splunkjs/mvc, "myapp/spinner.js", "myapp/modal.js"]);
However, none of the files modal or spinner are loading. I'm getting a RequireJS scripterror, along with a 404, from the Splunk setup page when i try to load the page, which is crashing the JS.

VM138:1903 GET http://10.X.X.X:8000/en-US/static/@e21ee54bc796.107/app/myapp/javascript/spin.js net::ERR_ABORTED 404 (Not Found) setup_page:1

Refused to execute script from 'http://10.X.X.X:8000/en-US/static/@e21ee54bc796.107/app/myapp/javascript/spin.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

I've tried moving around the files, changing names, changing from require.options to require("myapp/myscript") etc, to no avail..

Im stumped and don't know how to continue. Please if there are any suggestion, shoot!

0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

I think all you have to do is restart SplunkWeb. The front end won't believe that the file exists unless it sees the file itself during startup. It's a bit silly but it's a very longstanding annoyance.

eg: https://answers.splunk.com/answers/24407/application-js-not-loading.html

View solution in original post

0 Karma

sideview
SplunkTrust
SplunkTrust

I think all you have to do is restart SplunkWeb. The front end won't believe that the file exists unless it sees the file itself during startup. It's a bit silly but it's a very longstanding annoyance.

eg: https://answers.splunk.com/answers/24407/application-js-not-loading.html

0 Karma

christoffertoft
Communicator

Thanks, ended upp doing that and a few other modifications, and it worked. Not sure if the restart was the trick or some other hack, but it works now.

0 Karma
Get Updates on the Splunk Community!

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...

Understanding Generative AI Techniques and Their Application in Cybersecurity

Watch On-Demand Artificial intelligence is the talk of the town nowadays, with industries of all kinds ...