Refused to apply style from 'http://localhost:5000/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. code example

Example 1: stylesheet not loaded because of mime-type

put your .css file in a folder called public
in your app.js file add the following code:

app.use(express.static('public'));

Example 2: Refused to apply style from 'http://localhost:3000/css/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

app.get('/style.css', function(req, res) {
  res.sendFile(__dirname + "/" + "style.css");
});

Tags: