I'm trying to load a page that uses JS (in a different location) from Express. However when I load the page, I always get a MIME type mismatch, like the following:
The resource from “http://localhost:3000/home/lucid-user/lucid/lucidApp-ubuntu/node_modules/datamaps/dist/datamaps.world.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
I've seen that the error comes as the script element rejects those responses with incorrect MIME types if the X-content option of nosniff
is passed. How can I either:
- Fix the content response to send the correct header (javascript)
- Remove the nosniff option
lucidmap.html
<!DOCTYPE html>
<html>
<script src="/home/lucid-user/lucid/lucidApp-ubuntu/node_modules/d3/build/d3.min.js"></script>
<script src="/home/lucid-user/lucid/lucidApp-ubuntu/node_modules/topojson/dist/topojson.min.js"></script>
<script src="/home/lucid-user/lucid/lucidApp-ubuntu/node_modules/datamaps/dist/datamaps.world.min.js"></script>
<div id="container" style="position: relative; width: 500px; height: 300px;"></div>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<script>
var map = new Datamap({element: document.getElementById('container')});
</script>
</body>
</html>
Express.js code snippet
app.get('/lucidmap', function(req, res) {
res.sendFile('/home/lucid-user/lucid/lucidApp-ubuntu/views/app/lucidmap.html');
});
Browser used is Mozilla 77.0.1 64-bit for Ubuntu.