1

Has anyone successfully dealt with this kind of error? [Error] Did not parse stylesheet at 'https://*****.***/core/assets/vendor/jquery.ui/themes/base/core.css?s2pf9q' because non CSS MIME types are not allowed in strict mode. This shows up in the console. The site works fine with aggregation enabled, but none of the style sheets load when it is turned off. I get 56 errors like the one above. If I go directly to the URL mentioned in the error message, the css shows up.

This only happens on the production server, running Apache 2.4 on Ubuntu 20.04.6 LTS. The server is overprovisioned, and has plenty of resources. It works fine locally (ddev). This is a Drupal 9 site, with a theme based on ZURB Foundation 6 9.0.0-beta1. There are lots of references to this error on various support sites, but none of them are applicable to my situation.

6
  • What does curl -I "<that_css_url>" say its MIME type is? You can also get this information on the "network" tab of your browser's dev tools by clicking on that CSS resource. Most dev tools will show the response headers there.
    – cilefen
    Oct 19, 2023 at 17:57
  • What do you see when you access the path directly? This often is a result when the CSS file does not actually exist, as an HTML 'page not found' page with an HTML mime type is returned.
    – Jaypan
    Oct 19, 2023 at 22:40
  • @ Jaypan The question reads “If I go directly to the URL mentioned in the error message, the css shows up.” The web server is serving the file but probably with the wrong MIME type.
    – cilefen
    Oct 19, 2023 at 23:11
  • curl -I "<that_css_url>" returns text/html from the server, and text/css locally. Can I change that somehow? Oct 20, 2023 at 22:25
  • The /etc/mime.types file on the server does contain text/css css, so it should be returning text/css, no? Oct 20, 2023 at 22:35

1 Answer 1

0

Library declaration

First of all be sure to load your custom assets in the right way like describe in the Drupal documentation : Adding assets (CSS, JS) to a Drupal module via *.libraries.yml

Assets preprocessing

Fox fixing the problem you can try to disable the assets preprocessing from this page /admin/config/development/performance or with this commands and then clear cache :

drush -y config-set system.performance css.preprocess 0
drush -y config-set system.performance js.preprocess 0
drush cr

File permissions

Another reason to this error might be a file permission problem.

To be sure to have correct permissions you should run following commands (assuming you SSH user is user) :

cd /var/www/drupal/web
chown -R user:www-data .
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
find . -type f -exec chmod u=rw,g=r,o= '{}' \;

cd /var/www/drupal/web/sites
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
find ./*/files -type d -exec chmod ug=rwx,o= '{}' \;
find ./*/files -type f -exec chmod ug=rw,o= '{}' \;

Go check the docs about that : Securing file permissions and ownership

Apache configuration

Check Administrator -> Configuration -> Media -> File System to personalize your tmp path (assuming /tmp). Make sure to use relative paths and have the right privileges for the Apache user (assuming user).

chown -R user:www-data /tmp
chmod 777 /tmp

In your Apache configuration be sure to disable mod_userdir and in your VirtualHost configuration or your HtAccess file set AllowOverride All.

2
  • This is the opposite of our problem. The aggregated css loads fine. All site assets are contributed modules and themes that work fine on other servers, so it is doubtful that your second comment would apply. Oct 25, 2023 at 16:36
  • Have to try to disable assets preprocess at least ? If it's working it means that you have a script mode enabled in your Apache configuration. If not working it means that you have a file permission problem (chmod 755 sites/default/files) Oct 26, 2023 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.