javascript - 无法加载模块脚本 : The server responded with a non-JavaScript MIME type of "text/plain". 严格的 MIME 类型检查 i

标签 javascript python django

在 Django 中构建调试工具栏时,我在文件 toolbar.js 中遇到错误,即。
s.map:HTTP 错误:状态码 404,net::ERR_UNKNOWN_URL_SCHEME
toolbar.js:1 加载模块脚本失败:服务器以“text/plain”的非 JavaScript MIME 类型响应。根据 HTML 规范对模块脚本强制执行严格的 MIME 类型检查。
谁能告诉我可能的解决方法?

最佳答案

我在这里找到了解决方案 How to set content type of JavaScript files in Django

#settings.py
if DEBUG:
    import mimetypes
    mimetypes.add_type("application/javascript", ".js", True)

关于javascript - 无法加载模块脚本 : The server responded with a non-JavaScript MIME type of "text/plain". 严格的 MIME 类型检查 i,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64013643/

相关文章:

javascript - 如何在javascript中从JSON对象获取没有键的值

python - 如何在 Django 中调用 "MATLAB engine for Python"?

python - request.POST ['time' ] 必须是 datefield()

python - DRF 序列化程序更新嵌套用户

javascript - 谷歌图表 : Y-Axis numbers not visible

javascript - 计算 indexedDB 中对象存储中的记录数

Javascript/jQuery : Why is the focus event not firing on an input field?

python - 如何设计和自定义 tkinter/guizero 菜单栏?

python - Tensorflow记录: how to read and plot image values?

python - 随机 Python 模块和创造机会