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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...