Magento 2 MIME type ('text/html') is not executable, and strict MIME
Asked Answered
U

7

7

im new in Magento 2, and i already getting annoyed with it, i made a fresh installation, and in the browser setup all looks ok, after successfully instalation on frontend and backend im getting a error, i cant login on the administration panel, when i load the admin page is giving me this error:

Refused to execute script from '<URL>' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

I checked online and many of the comments stated that was missing htacess, in pub/static, but everything is fine, i already clean cache, compile, deploy, etc.. I did it all, but cant understand why still i get the error...

enter image description here

Frontend Error: enter image description here

Note: The strange thing im checking in the console error of the frontend is the error line

http://mageuniversity.local/Magento_Theme/js/responsive.js net::ERR_ABORTED 404 (Not Found)

I dont understand how the hell is looking in the root path the "Magento_Theme/js.." have no idea.

Unbreathed answered 30/1, 2019 at 1:13 Comment(4)
have you found any solution for this?Alduino
I am also got fed up with this. I have already spent my four day on this. still facing this issue.Decoction
I had this issue just now, but it was due to indicating the the wrong module in the layout/default.xml where I was referencing this, fixed that and this was fixedStarter
I was facing this issue on an Adobe Commerce Cloud project. Following below steps helped me to resolve the issue Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. https://mcmap.net/q/1620941/-magento-2-backend-mime-type-39-text-html-39-is-not-executable-and-strict-mimeDisincentive
P
5

Static files has not been deploy , try

php bin/magento setup:static-content:deploy -f de_DE // or your language code

Also keep dev mode on it will show errors

php bin/magento deploy:mode:set developer

If still you have same issues run the following commands

rm -rf var  generated/* pub/static/*  

chmod 777 -R var generated pub

and then again

php bin/magento setup:static-content:deploy -f
php bin/magento deploy:mode:set developer
Pico answered 5/2, 2019 at 9:0 Comment(3)
Tried this. still facing issue.Decoction
Run these commands rm -rf var generated pub/static mkdir var generated pub/static chmod 777 -R var generated pubPico
It's not working fine and stopped my website with 500Vittle
W
1

Try the two magento mode production / developer

bin/magento deploy:mode:set {mode} [developer|production]

Check also the owner of all your folders, I think your magento can't create static files.

Wertz answered 5/2, 2019 at 9:44 Comment(1)
tried both developer and production mode. still facing this issue.Decoction
A
1

It seems you may be missing an important .htaccess file located in pub/static, make sure it is there. If not copy the one from GitHub Magento repo - https://github.com/magento/magento2

If you're not missing the file then it must be an issue with mod rewrite, make sure you've installed it and it is configured properly.

Annunciation answered 21/6, 2019 at 6:56 Comment(0)
T
1
<-- Changes in app\code\Magento\Developer\etc\di.xml -->

 Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink  

    -- to --

 Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

First please delete 'static' folder from 'pub/static' in magento 2 before delete this folder please copy .htaccess file from this folder in other folder in your pc. After that using cmd/shell run these commands

php bin/magento setup:static-content:deploy -f

and

php bin/magento deploy:mode:set developer

and

php bin/magento cache:clean

after runing these commands .Paste old .htaccess file into new static folder. Thats it.

Your project working now enjoy!

Tonneau answered 7/2, 2020 at 6:5 Comment(2)
If you could add some clarity to this it would be more beneficial.Metritis
Thanks for comment for more clarity in this.Tonneau
W
1

This error could appear when you add Js file in a wrong way. For example when you add ".js" to the end of the file.

FOR EXAMPLE:

WRONG

/*in a template*/
<script type="text/x-magento-init">
    {
        "*": {
            "Vendor_Module/js/script.js": {
                "variable": "something"
            }
        }
    }
</script>

//OR
/*in a require-config.js file */

var config = {
    config: {
        mixins: {
            'Vendor_Module/js/catalog-add-to-cart': {
                'Vendor_Module/js/catalog-add-to-cart/mixin.js': true
            }
        }
    }
};

RIGHT

/*in a template*/    
<script type="text/x-magento-init">
    {
        "*": {
            "Vendor_Module/js/script": {
                "variable": "something"
            }
        }
    }
</script>

//OR
/*in a require-config.js file */

var config = {
    config: {
        mixins: {
            'Vendor_Module/js/catalog-add-to-cart': {
                'Vendor_Module/js/catalog-add-to-cart/mixin': true
            }
        }
    }
};
Wastepaper answered 13/10, 2021 at 8:0 Comment(0)
H
0

In Magento version 2.4.5-p1. I faced the same issue. In my case the javascript model path was wrong.

define([
    'ko',
    'Vendor_Module/js/model/payment/google_pay'
], function (ko) {
    'use strict';

    return ko.observableArray([]);
});

I given incorrect path Vendor_Module/js/model/google_pay correct path was

Vendor_Module/js/model/payment/google_pay

So please check the javascript file path. Thank You.

Haircut answered 16/7, 2023 at 9:46 Comment(0)
C
0

I fixed this problem with 2 different approach. I am explaining fixes;

1- If you are using cloudflare create rule

          Rules-Transform Rules -Modify response header - Create Rule
    If  custom filter expression 
URI ends with js
    than
add Content-Type = text/javascript

2- php.ini -- You can change default_mimetype

; PHP's built-in default media type is set to text/html.

; https://php.net/default-mimetype

default_mimetype = "text/html"

Choli answered 3/10, 2023 at 18:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.