FredRoger
FredRoger

Reputation: 1565

Magento 2 CSS doesnt generate static/_cache folder and throw a "blocked due to MIME type (“text/html”) mismatch" error

Here the whole error message: The resource from “https://example.com/static/_cache/merged/423594d2c9a788a2af3e706167e88c9f.min.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Context: I had an existing project to debug. Everything went well in local environment. I deployed in staging; everything went well too. In production I got the MIME type error when deploying. The front-end is ok, I only got this in back-end.

Project is on Magento 2.1.1. Production is on NGINX. Everywhere else on apache.

I know that they were an attempts to upgrade to 2.3.1 and it was rollbacked.

I'm deploying using this procedure:

  1. Checkout branch
  2. Composer update
  3. bin/magento
  4. rm -rf var/cache/*
  5. rm -rf var/page_cache/*
  6. rm -rf var/generation/*
  7. rm -rf pub/static/*
  8. rm -rf var/view_preprocessed/*
  9. rm -rf var/di/*
  10. rm -rf generated/code/* generated/metadata/*
  11. php bin/magento maintenance:enable
  12. php bin/magento setup:upgrade
  13. php bin/magento setup:di:compile
  14. php bin/magento setup:static-content:deploy
  15. php bin/magento maintenance:disable
  16. php bin/magento cache:flush
  17. find . -type f -exec chmod 644 {} \;
  18. find . -type d -exec chmod 755 {} \;
  19. find ./var -type d -exec chmod 777 {} \;
  20. chmod -R 777 ./pub/media/
  21. chmod -R 777 ./pub/static/
  22. chmod 777 ./app/etc
  23. chmod 644 ./app/etc/*.xml

I get no errors anywhere, except the one above in the browser console.

If you could have any hint for me, I'm lost! :)

Upvotes: 1

Views: 982

Answers (1)

bdbdbd
bdbdbd

Reputation: 503

This is probably because it ends up in a 404. In my case I fixed it by changing

web/secure/base_static_url and web/secure/base_static_url

from {{secure_base_url}}static/ and {{secure_base_url}}static/

to {{secure_base_url}}pub/static/ and {{secure_base_url}}pub/static/ respectively.

I'm not sure exactly why it is served from the pub folder in this case while my other Magento projects don't have this and I suspect it's a Valet or Nginx misconfiguration in my own case.

Upvotes: 0

Related Questions