openshiftopenshift-web-console

Openshift web console - running an extension script doesn't work


I'm reading through https://docs.openshift.com/container-platform/3.9/install_config/web_console_customization.html#loading-custom-scripts-and-stylesheets, which says for me to do the following, which I've done:

oc edit configmap/webconsole-config -n openshift-web-console

// I put in the below (obviously with a correct URL):
  scriptURLs:
    - https://url-for-a-js-file

// And also tried it with the below:
      scriptURLs:['https://url-for-a-js-file']

The JS file above looks something like this:

(function() {
console.log('---testing a script!---');
}());

Neither of these methods work, however. The console never shows the logged statement.

I know the documentation says "Scripts and stylesheets must be served with the correct content type or they will not be run by the browser. Scripts must be served with Content-Type: application/javascript and stylesheets with Content-Type: text/css.", but I'm not sure how to 'serve' a file like that if I'm just linking it from an HTTPS server (in this case a gitlab URL).


Solution

  • It looks like you are pointing to an external github or a gitlab URL for the script. You have to have that file be hosted somewhere else.