Refused to apply style because MIME type is not supported

孤街醉人 提交于 2019-12-24 11:01:16

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/50691921/refused-to-apply-style-because-mime-type-is-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!