Javascript Vue.js和django MIME类型问题

Javascript Vue.js和django MIME类型问题,javascript,django,vue.js,heroku,mime-types,Javascript,Django,Vue.js,Heroku,Mime Types,我正在向heroku部署一个嵌套在django项目中的vue.js应用程序。我一字不差地遵循了这个指南 构建到heroku成功,网站加载——例如,所讨论的网站的API部分是完全可查看的 但我无法访问vue.js应用程序,因为存在MIME类型问题。错误日志: The resource from “https://heseltime.herokuapp.com/static/css/app.48175cc56e52e020bf178616c0977374.css” was blocked due

我正在向heroku部署一个嵌套在django项目中的vue.js应用程序。我一字不差地遵循了这个指南

构建到heroku成功,网站加载——例如,所讨论的网站的API部分是完全可查看的

但我无法访问vue.js应用程序,因为存在MIME类型问题。错误日志:

The resource from “https://heseltime.herokuapp.com/static/css/app.48175cc56e52e020bf178616c0977374.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

根据我的django项目中的url.py,是vue.js应该位于的位置

from django.contrib import admin
from django.urls import path, include

from django.views.generic import TemplateView
from django.conf.urls import url

urlpatterns = [
    path('admin/', admin.site.urls),
    url(r'^$', TemplateView.as_view(template_name='index.html')),
    path('api_example', include('api_example.urls')),
]


当我ssh到heroku端时,我根据django中的my settings.py在正确的staticfiles位置找到文件

# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = [
  os.path.join(BASE_DIR, 'dist/static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

CORS_ORIGIN_ALLOW_ALL = False 

网站的html加载为


<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8>
    <meta name=viewport content="width=device-width,initial-scale=1">
    <title>heseltime</title>
    <link href=/static/css/app.48175cc56e52e020bf178616c0977374.css rel=stylesheet>
</head>
<body>
    <div id=app></div>
    <script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script>
    <script type=text/javascript src=/static/js/vendor.7e9567d6dec21d8821f2.js></script>
    <script type=text/javascript src=/static/js/app.f5b30ee15ad2f9646708.js></script>
</body>
</html>


黑塞尔泰

这对我来说很好(?)这可能是CORSHeaders的问题吗?

对所有
css
js
的请求都会导致找不到-显然服务器会发送一个带有“file not found”消息的html响应,这就是mime类型不匹配的原因-问题是这些文件不存在,与CORS无关,因为请求是相同的。谢谢,你是对的。该问题也是由于缺少白噪声中间件造成的。(忘记在settings.py中添加中间件。添加该行后,静态文件/将正确可用。)您能帮我研究一下类似的问题吗。