首页 > 解决方案 > 拒绝应用样式,因为它的 MIME 类型('application/octet-stream')

问题描述

我在使用版本控制时导入 css 和 javascript 时遇到问题。看来,当我使用 styles.css 和 script.js 时,一切正常,但是当我使用styles.css?v=1.1script.js?v=1.1时- 我收到以下错误。

Refused to apply style from 'url/goes/here/styles.css?v=1.1' because its MIME type ('application/octet-stream') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Refused to execute script from 'url/goes/here/script.js?v=2.1' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled.

这可能是什么原因?!

它们是这样导入的:

<link rel="stylesheet" type="text/css" href="url/goes/here/styles.css?v=1.1">

<script type="text/javascript" src="url/goes/here/script.js?v=1.1"></script>

标签: javascripthtmlcssmime-types

解决方案


我认为问题出在服务器上,"content-type"将 css 文件更改为"text/css"js 文件更改为"text/javascript",应该可以解决问题


推荐阅读