I have a web page that is pulling in some external JS files. The script tags are very simple, just plain old
<script type="text/javascript" src="https://oursite.com/a-valid-file.js"></script>
After a recent server update, all of these files are failing to load with the following error:
The resource from “https://oursite.com/a-valid-file.js” was blocked due to MIME type (“application/unknown”) mismatch (X-Content-Type-Options: nosniff).
I have tried:
- Pulling in the JS by appending it to the tag, and explicitly changing the type like so:
var jsfile = document.createElement("script");
jsfile.src = "https://oursite.com/a-valid-file.js";
jsfile.async = true;
jsfile.type = "application/javascript"; //have tried several here
var head = document.getElementsByTagName('head')[0];
head.appendChild(jsfile);
Changing the encoding of the JS file to UTF-8, ANSI, and other encodings (made no difference)
Trying different browsers (Edge, Chrome, and Firefox all give the same result)
I don't control the server - it's hosted and managed by another team. My questions are:
Why is this error occurring?
Can I fix this on my own by changing my file in some way?
If I have to ask the server team to make a configuration change, what change would I need to ask for?