简体   繁体   English

拒绝应用“ <URL> &#39;,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型,并且启用了严格的MIME检查

[英]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

friends, I've spent the whole day looking for the solution to this but I haven't been able to fix it. 朋友们,我整天都在寻找解决方案,但是我无法解决它。 I get this when I build it for production, in development mode (with no minification and stuff) it works well in localhost, but when I get my files in the dist folder and upload them to hosting server I get this error: 当我将其构建为生产环境时,在开发模式下(没有任何压缩和填充),在本地主机上可以很好地工作,但是在dist文件夹中获取文件并将其上传到托管服务器时,出现此错误:

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. 拒绝应用来自'<URL>'样式,因为它的MIME类型('text / html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查。

I stopped using CDNs that have comments at the beginning, and downloader the code and saved it locally and removed all comments. 我停止使用开头带有注释的CDN,并下载了代码并将其保存在本地并删除了所有注释。 (The most accepted answer here is that comments at the beginning mess up everything when the minification process occurs, but even doing that, I still get the error) (这里最被接受的答案是,在缩小过程发生时,开始时的注释会混淆所有内容,但是即使这样做,我仍然会收到错误)

Any help will be extremely appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

I have one way for problem solution, but you need to put your css in .php file under style tag. 我有一种解决问题的方法,但是您需要将CSS放在样式标记下的.php文件中。

//PHP code for get server url put it at top of in .php file

    $base_url = '://'. $_SERVER['HTTP_HOST'].'/'; //URL for server(CDN)
    $image_url = 'assets/image/';
    $url_for_image_dir = $base_url.$image_url;

HTML content HTML内容

 <html> <head> <title>css for url</title> </head> <body> <style> .slider-image{ background-image: url("<?php echo $url_for_image_dir;?>embouchure.jpg"); } </style> <div class="slider-image"></div> </body> </html> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝从...应用样式,因为它的 MIME 类型 (&#39;text/html&#39;) 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查 - Refused to apply style from... because its MIME type ('text/html') is not a supported style-sheet MIME type, and strict MIME checking is enabled 拒绝应用{filename}中的样式,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型 - Refused to apply style from {filename} because its MIME type ('text/html') is not a supported stylesheet MIME type Django:拒绝从...应用样式,因为它的 MIME 类型(&#39;text/html&#39;)不是受支持的样式表 MIME 类型 - Django: Refused to apply style from ... because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型 - Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自“xxx/style.css”的样式,因为它的 MIME 类型(“text/html”)不是受支持的样式表 MIME 类型 - Refused to apply style from 'xxx/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝从 &#39;URL&#39; 执行脚本,因为它的 MIME 类型 (&#39;text/html&#39;) 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script from 'URL' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled Angular 6:拒绝从“URL”执行脚本,因为它的 MIME 类型()不可执行,并且启用了严格的 MIME 类型检查 - Angular 6 : Refused to execute script from 'URL' because its MIME type( ) is not executable, & strict MIME type checking is enabled 拒绝应用样式,因为它的 MIME 类型('text/html')不是受支持的样式表类型 - Refused to apply style because its MIME type ('text/html') is not a supported stylesheet type 拒绝从“ file_name.php”执行脚本,因为其MIME类型(“ text / html”)不可执行,并且启用了严格的MIME类型检查 - Refused to execute script from 'file_name.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled 启用了严格的 mime 类型检查,拒绝执行来自 ' 的脚本<url> ' 它的 mime 类型 ('text/plain') 是不可执行的,并且</url> - strict mime type checking is enabled, refused to execute script from '<url>' its mime type ('text/plain') is not executable, and
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM