首页 > Web开发 > 详细

Nginx部署静态html样式不正确 Resource interpreted as Stylesheet but transferred with MIME type text/plain

时间:2020-05-25 20:49:37      阅读:129      评论:0      收藏:0      [点我收藏+]

将网站部署到 nginx 之后,网页可以打开,但样式全都没有加载,浏览器里按下 F12 键,console 有报错:

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

由于 nginx 没有指定 mime type,则默认会以 text/plain 的形式处理,也就是说,浏览器会以纯文本的形式来处理 css 和 js 文件,所以无法正常加载样式。

修改配置文件 nginx.conf, 在 http{ } 中开启下面两行(一般 nginx.conf 文件中默认是有下面的配置的):

include /etc/nginx/mime.types;
default_type application/octet-stream;

重启nginx服务即可。

Nginx部署静态html样式不正确 Resource interpreted as Stylesheet but transferred with MIME type text/plain

原文:https://www.cnblogs.com/manastudent/p/12960590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!