## 由于最近在部署 CI 的项目,静态的 css 一直没有生效,导致部分格式错误
具体错误提示为:
Error: The stylesheet http://example.com/style.css was not loaded
because its MIME type, "text/html", is not "text/css".
错误原因: http Header Content-Type没有指定文件类型
解决方式:
1. 查看 nginx.conf 文件中,http{ } 内是否有
include mime.types;
default_type application/octet-stream;
## 没有就添加。 但 一般都有这个,只是确认下而已,所以不用做什么修改;
2. 手动添加Header Content-Type文件类型
location ~ \.css {
access_log logs/css.access.log;
error_log logs/css.error.log;
root /data/**/**/;
index index.htm index.html index.php;
add_header Co

在部署CI项目时遇到静态CSS文件未生效的问题,表现为格式错误。错误提示显示HTTP未指定文件类型。解决方案包括检查`nginx.conf`中是否已包含配置,并手动添加Header设置Content-Type,确保指定静态文件的根路径,以防止出现404错误。
最低0.47元/天 解锁文章
1229

被折叠的 条评论
为什么被折叠?



