Django digitalocean Spaces 请求的资源上不存在“Access-Control-Allow-Origin”标头

Wil*_*iam 5 django nginx digital-ocean django-cors-headers

我的 Django 网站使用 Nginx 托管在 digitalocean ubuntu 16.04 中。

我已经在这里设置了 digitalocean CORS 配置https://www.digitalocean.com/docs/spaces/how-to/cors/我在“来源”中添加了我的域名,检查了“允许的方法”中的所有选项,我唯一没有做的就是在“Alowed Headers”中添加标题,因为我不知道要添加什么。

当我使用 digitalocean Spaces(一种基于并与 Amazon S3 非常相似的服务)作为我的静态和媒体文件存储时。请求的资源错误中不存在“Access-Control-Allow-Origin”标头

CORS 政策已阻止从来源“ https://kjmg.co ”访问“ https://nyc3.digitaloceanspaces.com/kjmgstorage/kjmgstorage/fonts/fontawesome-webfont.woff2?v=4.7.0 ”上的字体:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问Origin ' https://kjmg.co '。

我尝试使用 django-cors-headers,但我收到:

502 错误网关 nginx/1.10.3 (Ubuntu)

所以只好卸载了。

有朋友知道吗?非常感谢!

1GD*_*DST 3

您需要在 Digital ocean 设置 CORS,而不是在您的网站上。检查这个:digitalocean.com/docs/spaces/how-to/cors