【发布时间】:2020-06-15 02:36:06
【问题描述】:
我正在使用 cloudfront 从 S3 存储桶分发我的静态文件。我使用 django 作为我的后端。我配置了我的云端以从我的 S3 存储桶中获取我的静态文件。对于 images 和 css 和 js 文件效果很好。但是对于html 文件却出现了这个错误:
Access to XMLHttpRequest at 'https://xxxxxxxx.cloudfront.net/static/partials/main.html?v=e720c74cfb39a5d17a1f5b4d75a496df30620a5c' from origin 'https://www.xxxxxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
但问题是我的其他文件下载正常,为什么我的 html 文件出现这些错误。
我的 pip 中安装了 django-cors-headers==1.1.0,并且我启用了所有 CORS_ORIGIN_ALLOW_ALL = True。但仍然出现错误。
【问题讨论】:
标签: django cors amazon-cloudfront