CSS not working after enabling HSTS

I have a Django site hosted on AWS EC2 behind nginx proxy server.

When I try to access the site, the CSS and javascript are not loaded with the error

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

After spending 2 days finding the issue, it was found that the website is working fine when the domain is not proxied through Cloudflare and gives an error when proxied.

The issue is happening due to enabling HSTS and No-Sniff Header.

After disabling No-Sniff Header, the website is working fine and loading all resources.

How can I serve the static files when the No-Sniff Header is enabled

If you check on the Network tab of your browsers dev tools, what status code do you see for these resources?

I expect it is not a 200, but a 40x error or similar. Identifying the cause of the non-200 is usually the fix here (and not something related to MIME types).

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.