angularjs JS和CSS文件由于MIME类型不匹配而被阻止

zaqlnxep  于 2023-04-28  发布在  Angular
关注(0)|答案(1)|浏览(209)

当我登录我的应用程序的URL,它在前端使用角JS并在JBoss服务器上运行,JS和CSS文件加载状态为200,但我仍然得到下面的错误,文件没有得到执行,我已经用文本URL替换了原始URL用于隐私目的:
在Chrome浏览器中:

Refused to apply style from 'URL/bootstrap-glyphicons.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Refused to execute script from 'URL/angular.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

在Firefox浏览器中:

The resource from “URL/bootstrap.min.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

The resource from “URL/angular-route.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

我们正在使用URL和应用程序服务器之间的Web服务器,其中设置了标题。有标题X-Content-Type-Options:nosniff设置。在应用服务器级别,我找不到与此相关的任何设置。我不明白为什么MIME类型被返回为text/html。我已经检查了网络选项卡中的每个资源,那里的内容类型有时会显示为application/javascript;对于JS文件,charset=UTF-8,有时它会显示为text/html;字符集=UTF-8

2lpgd968

2lpgd9681#

请检查文件路径是否正确,文件是否存在,在我的情况下,这是问题,因为我修复了它,错误消失.希望它也能为你工作。

相关问题