NGINX Mime 类型

del*_*ueg 5 nginx mime-types

我有以下问题:

https://my.domain.com/js/some_js_file.js

加载良好,但是:

https://my.domain.com/some_other_folder/some_js_file.js

出现以下错误:

拒绝执行“ https://my.domain.com/some_other_folder/some_js_file.js ”中的脚本,因为其 MIME 类型(“text/html”)不可执行,并且启用了严格的 MIME 类型检查。

现在,在我们的负载均衡器进行安全更新后,就会发生这种情况。

我尝试了几件事。

添加:

location ~ \.js {
   add_header  Content-Type    application/x-javascript;
}
Run Code Online (Sandbox Code Playgroud)

或者:

location ~ \.js {
   add_header  Content-Type    application/javascript;
}
Run Code Online (Sandbox Code Playgroud)

改变了/etc/nginx/mime.types

从:

    application/x-javascript              js;
Run Code Online (Sandbox Code Playgroud)

到:

    application/javascript              js;
Run Code Online (Sandbox Code Playgroud)

什么都不起作用,我不明白并非所有文件都会引发此错误。/some_other_folder/仅位于以下位置或外部的文件/js/