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
Stylesheets should have a MIME type of text/css
. Your server is serving up a HTML document (probably a 404 NOT FOUND error page) when it should be serving a CSS document.
Solution:
In my case, the problem was an empty @GetMapping
in one of my Controllers. I deleted it and the problem was gone.
I think the same answer will help someone who's having this similar problem and context ; e.g. JSP.
Background:
I had the same problem using Spring Boot and FreeMaker.
I've found that using a path that includes the domain, rather than just a relative path to the file, fixes the issue.
I.e:
src="https://<domain>.com/public/css/style.css"
rather than:
src="../../public/css/style.css"
I don't have a reason as to why this is the case. Perhaps something to do with the way static files are being served, or because it needs to be served over https
. I'm using Firebase to host / serve.
Note that this works for both css
and js
files, and explicitly setting the MIME type didn't have an effect for me.