我有这个问题。Chrome继续返回此错误
资源解释为样式表,但以MIME类型text/html传输
受此错误影响的文件只有Style、chosen和jquery-gentleselect(以相同方式导入索引的其他CSS文件工作良好且没有错误)。我已经检查了我的MIME类型和文本/css已经在css上。
老实说,我想从理解问题开始(这似乎是我一个人做不到的事情)。
我有这个问题。Chrome继续返回此错误
资源解释为样式表,但以MIME类型text/html传输
受此错误影响的文件只有Style、chosen和jquery-gentleselect(以相同方式导入索引的其他CSS文件工作良好且没有错误)。我已经检查了我的MIME类型和文本/css已经在css上。
老实说,我想从理解问题开始(这似乎是我一个人做不到的事情)。
当前回答
试试这个<link rel="stylesheet" type="text/css" href="../##/yourcss.css">
哪里##是你的文件夹,其中是你的。css -文件
别忘了:..(双点)。
其他回答
试试这个<link rel="stylesheet" type="text/css" href="../##/yourcss.css">
哪里##是你的文件夹,其中是你的。css -文件
别忘了:..(双点)。
根据其他的回答,这条消息似乎有很多原因,我想我只是分享我的个人解决方案,以防将来有人有我的确切问题。
Our site loads the CSS files from an AWS Cloudfront distribution, which uses an S3 bucket as the origin. This particular S3 bucket was kept synced to a Linux server running Jenkins. The sync command via s3cmd sets the Content-Type for the S3 object automatically based on what the OS says (presumably based on the file extension). For some reason, in our server, all the types were being set correctly except .css files, which it gave the type text/plain. In S3, when you check the metadata in the properties of a file, you can set the type to whatever you want. Setting it to text/css allowed our site to correctly interpret the files as CSS and load correctly.
使用的反应
我在我的react profile应用程序中遇到了这个错误。我的应用程序表现得有点像它试图引用一个不存在的url。我相信这与webpack的行为有关。
如果你在公用文件夹中链接文件,你必须记住在资源之前使用%PUBLIC_URL%,就像这样:
<link type="text/css" rel="stylesheet" href="%PUBLIC_URL%/bootstrap.min.css" />
我的问题比这篇文章中的所有答案都要简单。
我必须设置IIS以包含静态内容。
将匿名身份验证凭据设置为应用程序池标识对我来说很有用。