cancel
Showing results for 
Search instead for 
Did you mean: 

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

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

Hi, 

Suddenly CSS is not loading on my Magento 2 admin panel. The frontend is working fine. 

Error details:

 

1.  "Refused to apply style from 'https://www.ornativa.com/pub/static/version1502029409/adminhtml/Magento/backend/en_US/css/styles-old...' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."

 

2.   "Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at callback ((index):68)
at Object.execCb (require.js:1650)
at Module.check (require.js:866)
at Module.<anonymous> (require.js:1113)
at require.js:132
at require.js:1156
at each (require.js:57)
at Module.emit (require.js:1155)
at Module.check (require.js:917)"

 

 

Screen Shot 2018-02-07 at 1.31.01 PM.png

 

17 REPLIES 17

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

The mime type is HTML is a bit of a misnomer. While that is the problem, the actual problem is that your the URL for CSS is returning a web server or Magento error rather than the CSS file it's mean to. 

 

If you visit the URL that you shared https://www.ornativa.com/pub/static/version1502029409/adminhtml/Magento/backend/en_US/css/styles-old..., you get a Magento error page. 

 

The CSS seems to be working on the frontend so not sure why it wouldn't be on admin, have you changed anything here recently. Can you regenerate the static files using the instructions on http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-static-view.html to see if that helps.

 

If it doesn't, the next step would be see if you can find the file it's trying to load on the filesystem. If it's there, it would point to a web server configuration problem instead. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

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

As for the second part of the issue, you should have a closer look at what JSON returns, search for an error in it and where it comes from.

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

Recently had a very similar issue with a Magento 2 site. Managed to track down the issue to a very import .htaccess file being missing in the pub/static folder on the server.

 

Re-adding this file from a clean Magento 2 installation rectified the issue.

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

Hello,

 

It is happen when CSS file is not there, please create same name file or do static content deploy for same.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

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

Hi, could you pls explain briefly.

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

Hello @Jeeva Rathinam

 

Some time CSS created based on setting, so may be you need to go to that theme setting and save it so it will create that file.( e.g porto doing same thing)

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

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

Go into your dir /magento/pub/static/version1525190041/adminhtml/Magento/backend/en_US/css/ and you will find 
'styles-old.css' - remove the 'old'. 

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

Thank you very much. It worked for me, because of porto-theme!

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

You are my saviour. If I could buy you a beer, I would.