angular项目部署到nginx,css样式文件加载出问题,报警:Resource interpreted as Stylesheet but transferred with MIME type text/plain

解决思路:

  项目部署之前一切运行正常,部署到nginx之后出问题,可从nginx部署环境下手考虑问题。

  警告信息:Resource interpreted as Stylesheet but transferred with MIME type text/plain

  说明文件可以找到,并且被加载了,但是加载类型不正确。

  nginx配置环境中,引入了mime.types文件,此文件告诉浏览器以何种方式处理文档(各类文件)。

  mime type常见的有两种:

    text/plain:以纯文本格式加载解析文件

    application/octet-stream:八进制数据文件

  通常我们会将浏览器无法识别的资源作为application/octet-stream类型加载。

解决方法:

  综上所述,我们可通过配置nginx环境下的CentOS7下,修改配置文件/etc/nginx/nginx.conf,在http{}中修改或添加以下两项配置:

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

  重启nginx服务

service nginx restart

  重新加载浏览器页面查看是否解决。

相关文章:

  • 2022-12-23
  • 2022-01-31
  • 2021-10-05
  • 2021-05-23
  • 2021-07-25
  • 2021-06-03
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2021-07-24
  • 2022-12-23
  • 2021-10-19
  • 2021-05-14
  • 2021-11-07
  • 2021-11-30
相关资源
相似解决方案