(Node Express)Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

chris jim

Refused to apply style because of MIME type. I can't serve css for my html page via Express. I've tried everything but I feel like I am overlooking something simple and just would like some fresh eyes to analyze my code to see where I am messing up at.

server.js

 app.use(express.static(path.join(__dirname + '/public')));

 app.get('/', (req, res)=> {
     res.sendFile(path.join(__dirname, 'index.html'))
 })

The index.html runs just fine but without any css styling.

My html css link is:

link rel = "stylesheet" type="text/css" href="styles.css"

and my file structure is

                     >backend
                      index.html
                      server.js

                     >public
                       styles.css
Amila

Your /public does not have a forward slash at the end, you can try it including in href your HTML.

link rel = "stylesheet" type="text/css" href="/styles.css"

Also, check your static public folder is actually set up correctly with provided path and that can access your styles.css file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

Refused to apply style because its MIME type "text/html" is not supported stylesheet MIME type, and strict MIME checking is enabled

Refused to apply style from 'URL' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

Refused to apply style from [Link] because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

"Refused to apply style from because its MIME type "('font/woff2')" is not a supported stylesheet MIME type, and strict MIME checking is enabled"

Refused to apply style from... because its MIME type ('text/html') is not a supported style-sheet MIME type, and strict MIME checking is enabled

Node refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME

Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type

Refused to execute script from because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to execute script from '*' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled

Error on minification in console "Refused to execute because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled"

Refused to execute script from URL because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled

Refused to execute script from 'file_name.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to execute script because strict MIME type checking is enabled

MIME type ('application/json') is not executable, and strict MIME type checking is enabled

Node/Express - Refused to apply style because its MIME type ('text/html')

Refused to execute script, strict MIME type checking is enabled?

Log In MIME type (‘text/html’) not a supported stylesheet MIME type

MIME type ('text/html') is not a supported stylesheet MIME type

NodeJS, MIME type ('text/html') is not a supported stylesheet MIME type

A Stylesheet is not being displayed due to its MIME type not being supported, though the MIME type appears blank when debugging

The stylesheet style.css was not loaded because its MIME type, “text/plain”, is not “text/css”

MIME type ('text/html') is not a supported stylesheet

Refused to apply style from 'http://localhost:3000/style.css' because its MIME type ('text/html')

Stylesheet not loaded because of MIME-type

Stylesheet not loading because MIME type is text/html

Refused to apply style from 'http://localhost:1234/node_modules/primeicons/primeicons.css' because its MIME type ('text/html')

Disable Chrome strict MIME type checking

Refusing to apply styles because MIME type