Currently, I have set up a Node.JS server for a new project at my workplace. As part of the project, I have created an optimizer function that removes unnecessary elements such as tabs, newlines, and comments from HTML, JavaScript, and CSS files.
Strangely, after adding
<link type="text/css" href="/css/bootstrap.mins.css">
to the header, it does not load or appear in the Google Network tab.
The main HTML page loads properly, but the CSS file is not loading.
Server:
app.get("/css/:file",function(req,res){
logger.log("CSS File");
res.writeHead(200, {"Content-Type": "text/css"});
res.write(fs.readFileSync(appRoot + "/css/" + req.params.file,"utf8").optimize());
res.end();
});
All CSS files are located in a single directory with no nesting. This setup should technically work, but it is not functioning as expected. The CSS file loads and is processed correctly when accessed directly via the URL, but not through the LINK tag.
https://i.sstatic.net/YqFMA.png
View of the loaded HTML Page: https://i.sstatic.net/bwmQt.png
Directly accessing the CSS file; it preprocesses correctly: https://i.sstatic.net/OZOBz.png