In my local NodeJS app file I'm trying to load HTML file with CSS link using jsdom module and then display it on the browser this way
var http = require('http'),
fs = require('fs'),
jsdom = require('jsdom');
http.createServer(function(req, res) {
if (req.url === '/favicon.ico') {
res.writeHead(404);
res.end();
return;
}
res.writeHead(200, {'Content-Type': 'text/html; charset=utf8'});
var indexPageHTML = fs.readFileSync('index.html');
var document = new jsdom.JSDOM(indexPageHTML,{resources: "usable"}).window.document;
var indexPageHTML = '<!doctype html><html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>';
res.end(indexPageHTML);
}).listen(80, 'localhost');
My index.html
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
Some text
</body>
</html>
But the CSS still isn't loaded and I still get the warning
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/style.css".
How should the resources: "usable" option work? Which is mentioned by the link https://www.npmjs.com/package/jsdom#basic-options