Django digitalocean Spaces所请求的资源上没有"Access-Control-Allow-Origin"标头 [英] No 'Access-Control-Allow-Origin' header is present on the requested resource with Django digitalocean Spaces

查看:183
本文介绍了Django digitalocean Spaces所请求的资源上没有"Access-Control-Allow-Origin"标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Django网站通过Nginx托管在digitalocean ubuntu 16.04中.

My Django website is hosting in digitalocean ubuntu 16.04 with Nginx.

我在此处设置了digitalocean CORS配置 https://www. digitalocean.com/docs/spaces/how-to/cors/我在来源"中添加了自己的domian名称,选中了允许的方法"中的所有选项,我唯一没有做的就是添加标题在允许的标题"中,因为我不知道要添加什么.

I have setup digitalocean CORS Configurations as here https://www.digitalocean.com/docs/spaces/how-to/cors/ I added my domian name in the 'origin',checked all the options in 'Allowed Methods',the only thing I haven't done is add headers in 'Alowed Headers' because I have no idea what to add.

当我使用digitalocean Spaces(一种基于服务且与Amazon S3非常相似的服务)作为我的静态和媒体文件存储时.所请求的资源上没有'Access-Control-Allow-Origin'标头错误:

When I use digitalocean Spaces(a service based on and very similar as Amazon S3) as my static and media file storage.There is No 'Access-Control-Allow-Origin' header is present on the requested resource error:

通过' https:访问字体: //源自来源"' noreferrer> https://kjmg.co "已被CORS策略阻止:所请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许访问来源" https://kjmg.co ".

Access to Font at 'https://nyc3.digitaloceanspaces.com/kjmgstorage/kjmgstorage/fonts/fontawesome-webfont.woff2?v=4.7.0' from origin 'https://kjmg.co' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://kjmg.co' is therefore not allowed access.

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

I tried to use django-cors-headers,but I received:

502 Bad Gateway nginx/1.10.3(Ubuntu)

502 Bad Gateway nginx/1.10.3 (Ubuntu)

因此必须将其卸载.

任何朋友有任何想法吗?非常感谢!

Any friend have any idea?Thank you so much!

推荐答案

您需要在Digital ocean而不是在网站上设置CORS.检查以下内容: digitalocean.com/docs/spaces/how-to/cors

You need to setup CORS at Digital ocean, not on your website. Check this: digitalocean.com/docs/spaces/how-to/cors

这篇关于Django digitalocean Spaces所请求的资源上没有"Access-Control-Allow-Origin"标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆