首页 > 解决方案 > 404 关于在 Django 应用程序中使用 Azure 存储

问题描述

我正在尝试在 Microsoft Azure 上部署 Django 应用程序。

我在Azure 虚拟机上使用 nginx + gunicorn 。为了提供静态和媒体文件,我决定使用Azure Storage中可用的Azure Blob

我正在使用以下库在我的应用程序中集成 Markdown + MathJax 编辑器 - django-mdeditor

现在,这个库带有自己的JSCSS文件。在以下情况下使用这个库我没有问题 -

但是,一旦我转移到 Azure 存储作为我的存储后端。我收到以下错误 -

Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)
codemirror.min.js:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

codemirror.min.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

dialog.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

codemirror.min.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

matchesonscrollbar.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

dialog.css:1 Failed to load resource: the server responded with a status of 404 (The specified blob does not exist.)

除了以上几个文件,其余的静态文件都被正确抓取了!

经过进一步调查,我发现上述所有文件都是从以下脚本中获取的 - https://github.com/pylixm/django-mdeditor/blob/master/mdeditor/static/mdeditor/js/editormd.js# L549

即来自以下代码块 -

.
.
editormd.loadCSS(loadPath + "codemirror/codemirror.min");
.
.

loadPathsettings.path在脚本中分配等于 (afaik) 的值'./lib/'

loadCSS()正在尝试从 url 获取文件 -https://edumate.blob.core.windows.net/static/mdeditor/js/libcodemirror/codemirror.min.js

而不是https://edumate.blob.core.windows.net/static/mdeditor/js/lib/codemirror/codemirror.min.js.

请注意在第一种情况下缺少/after 。lib生成的 URL.../libcodemirror/..不是../lib/codemirror/..!

使用或方法获取的所有其他文件也是如此,JS如上所示。CSSloadCSS()loadScript()

奇怪的是,这种删除/只会在使用 Azure 存储时发生,而不是在使用 Heroku、nginx + gunicorn 或开发服务器时发生。

关于如何调试的任何想法?

标签: djangoazureazure-storageazure-blob-storage

解决方案


推荐阅读