拒绝应用样式,因为不支持MIME类型 [英] Refused to apply style because MIME type is not supported

查看:2771
本文介绍了拒绝应用样式,因为不支持MIME类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b我一直得到一个错误,说MIME类型('text / html')不可执行或不支持样式表的MIME类型,并且严格的MIME检查被启用。 $ b

显示的错误



我的代码链接它,

 <! - 此模板的自定义样式 -  - > 
< link href =css / heroic-features.css =stylesheet>

<! - Bootstrap core JavaScript - >
< script src =vendor / jquery / jquery.min.js>< / script>
< script src =vendor / bootstrap / js / bootstrap.bundle.min.js>< / script>

这就是模板的样子模板 然而,这看起来像 Template

我需要更改text / html变成别的东西?

 接受:{
*:allTypes,
text:text / plain,
html:text / html,
xml:application / xml,text / xml,
json:application / json,text / javascript
},

Sinatra告诉我要做这个,但我试过了,它不起作用



有什么我应该改变或添加我的代码,以便该CSS工作?

解决方案

我想你会希望 text / css 用于你的样式表,而 application / javascript 用于JS文件。

sinatra文档,传入的请求对象可以从请求级别访问

  get'/ foo'do 
t =% w [text / css text / html application / javascript]
request.accept#['text / html','* / *']
request.ac CEPT? 'text / xml'#true
request.preferred_type(t)#'text / html'
end


I keep getting an error that says that the MIME type ('text/html') isn't executable or not a supported stylesheet MIME type and that strict MIME checking is enabled.

Error shown

My code that links it is,

<!-- Custom styles for this template -->
<link href="css/heroic-features.css" rel="stylesheet">

<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

This is how the template is supposed to look Template

However, this is what it looks like Template

Do I need to change text/html into something else?

accepts: {
        "*": allTypes,
        text: "text/plain",
        html: "text/html",
        xml: "application/xml, text/xml",
        json: "application/json, text/javascript"
    }, 

Sinatra is telling me to do this but I've tried and it doesn't work

Is there anything I should change or add to my code so that the css works?

解决方案

I imagine you'd want text/css for your stylesheets, and application/javascript for the JS files.

According to the sinatra docs, the incoming request object can be accessed from the request level

get '/foo' do
  t = %w[text/css text/html application/javascript]
  request.accept              # ['text/html', '*/*']
  request.accept? 'text/xml'  # true
  request.preferred_type(t)   # 'text/html'
end

这篇关于拒绝应用样式,因为不支持MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆