首页 > 代码库 > nginx - Resource interpreted as Stylesheet but transferred with MIME type text/plain

nginx - Resource interpreted as Stylesheet but transferred with MIME type text/plain

在部署前端项目的时候,网站跑起来了,可就是css样式没加载出来,查看css文件也已经load进来,被坑了3个小时终于发现问题所在:

nginx.conf中添加下面两行配置即可,可参考nginx默认配置文件

 

include mime.types;

default_type application/octet-stream;

 

如果不设置css文件就会被当作text/plain类型发送到浏览器。从而导致css样式无法显示

nginx - Resource interpreted as Stylesheet but transferred with MIME type text/plain