disable chrome strict MIME type checking on local dev

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

I have a CSS file that my local dev server (webpack) is serving up with apparently the wrong mime type.

Refused to apply style from 'http://localhost:10001/font-awesome/css/font-awesome.min.css'  because its MIME type ('text/html') is not a supported stylesheet MIME type,  and strict MIME checking is enabled.

Is there anyway to disable this? I assume it's a chrome setting. At least for a specific host.

Digging into the webpack config, if it doesn't do something basic like this is usually an exercise in frustrating yak shaving.

Most other answers refer to ways of fixing the server. I just want to hack this client side since the server is being stubborn.

related:

回答1:

Your question is from a while ago, but ranks well on Google for this problem so I wanted to chip in with a couple pointers.

It might be an HTTP/404 in disguise

The error message is probably just misleading you. It's unfortunate that Google Chrome removes the response entirely, even the preview of the "Network" dev panel.

The MIME type might be incorrect because the server is answering with an HTTP 404 message.
To test: Open the URL to the CSS file in the browser directly, or fetch it with a tool like wget.

Have you checked if the path is correct? Depending on your configuration the css file might not be where it was before (Assuming it's not a problem with webpack or its configuration).

I can just guess blindly here what the correct URL might be...
http://localhost:10001/node_modules/font-awesome/css/font-awesome.min.css
http://localhost:10001/css/font-awesome/font-awesome.min.css
http://localhost:10001/css/font-awesome.min.css
http://localhost:10001/font-awesome.min.css

Related answers
If this doesn't help, these had some helpful pointers to me:
Stylesheet not loaded because of MIME-type



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