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!

New Case Study Shows the Value of Partnering with Splunk Academic Alliance

The University of Nevada, Las Vegas (UNLV) is another premier research institution helping to shape the next ...

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...