No 'Access-Control-Allow-Origin' header is present on the requested resource with Django digitalocean Spaces

隐身守侯 提交于 2019-12-22 13:57:07

问题


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

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.

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:

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.

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

502 Bad Gateway nginx/1.10.3 (Ubuntu)  

So had to uninstalled it.

Any friend have any idea?Thank you so much!


回答1:


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



来源:https://stackoverflow.com/questions/52449377/no-access-control-allow-origin-header-is-present-on-the-requested-resource-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!