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

北城以北 提交于 2019-11-30 08:56:06

The problem is the result of an improperly named file. Our student had a space at the end of the style.css file. There were a few tip offs to this, the first was a lack of syntax highlighting in the text editor, and the second was the text editor detecting the filetype for other newly created css files but not the improperly named file. Removing the space resolved the issue.

Thank you slebetman for your help in pointing me in the right direction.

Surekha K

In NOdejs app with express we need to add the line like below to tell the server about the directory

app.use(express.static(__dirname));

This will solve the problem of css not rendering

This is not a solution for your question but this might help someone else searching for solution like me. if you use app.get like below:

app.get(express.static(path.join(__dirname,"public")));

change it to :

app.use(express.static(path.join(__dirname,"public")));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!