拒绝从 'bundle.js' 执行脚本,因为它的 MIME 类型'text/html'不可执行,并且启用了严格的 MIME 类型检查

问题描述

我有一个带有前端和 django 后端的 CRA 应用程序。我使用 react-app-rewired 覆盖前端的 webpack 配置,以便保存 webpack-dev-server 的输出以供 django 使用。

但是我遇到了问题,如下面的屏幕截图所示。

enter image description here

下面是我的 override-config.js,它用于覆盖开箱即用的 CRA webpack 配置

enter image description here

奇怪的事情是前端产品构建没有这样的问题(运行yarn build然后在浏览器中打开localhost:8000,我可以正确获取前端)。以上 Refuse to execute ... 问题仅在我为开发模式运行 yarn start 时发生。

这是我的 package.json

enter image description here

和 django frontend.html

enter image description here

django settings.py 中的相关部分

enter image description here

在此先感谢您的帮助!!!

解决方法

这是否仅在 Django settings.py 中的 sendPasswordResetEmail(email) 调试模式下发生?也许您会尝试将 DEBUG = True 添加到 urlpatterns

urls.py

assets

在此处引用 document