Search code examples
cssdjangodjango-adminpythonanywhere

CSS not working in Django admin: The resource from [css file url] was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff


Django admin is displaying without CSS because of the error: The resource from “my-website-address/static/admin/css/responsive.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

The CSS url I can open in my browser and it looks fine.

What can I do to fix CSS displaying for standard Django admin interface?


Solution

  • I got the error

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

    because one of my Cloudflare manually created firewall rules blocked CSS URLs. I discovered this when opened my Cloudflare dashboard and sow that firewall rule was applying 'JS challenge' to the URLs like https://[my-website]/static/admin/css/.

    So if your website can not load some resources and you get the error about MIME type please check your Cloudflare dashboard or try to temporary disable it.