tyles.css由于MIME类型("text/html")不匹配(X-Content-Type-O



我已经更改了我的主机,现在我收到css/js阻止错误was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff)。请帮助我。

请检查给我错误的js代码。

define([
'jquery',
'mage/smart-keyboard-handler',
'mage/mage',
'mage/ie-class-fixer',
'domReady!'
], function ($, keyboardHandler) {
'use strict';
if ($('body').hasClass('checkout-cart-index')) {
if ($('#co-shipping-method-form .fieldset.rates').length > 0 && $('#co-shipping-method-form .fieldset.rates :checked').length === 0) {
$('#block-shipping').on('collapsiblecreate', function () {
$('#block-shipping').collapsible('forceActivate');
});
}
}
$('.cart-summary').mage('sticky', {
container: '#maincontent'
});
$('.panel.header > .header.links').clone().appendTo('#store\.links');
keyboardHandler.apply();
});

首先,我尝试了所有步骤,例如

rm -rf var/*
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex 
php bin/magento cache:clean

仍然没有工作。(这些步骤是必需的,但不完整)

无论是否存在pub/static,都必须使用新文件更改.htaccess文件。
更改后,我再次运行cache:clean命令,然后它对我来说效果很好
大多数人可能会跳过这一步,因为.htaccess已经在pub/static中可用。

你可以在magento官方github中获得.htaccess新的:
https://github.com/magento/magento2/blob/2.3/pub/static/.htaccess
(适用于Magento 2.3,您可以在分支中选择合适的版本)

附言:如果您在运行命令时遇到内存耗尽错误,请尝试使用

php -dmemory_limit=5G bin/magento ...

最新更新