Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在ubuntu服务器上,nginx无法提供跨域图像url_Python_Django_Nginx - Fatal编程技术网

Python 在ubuntu服务器上,nginx无法提供跨域图像url

Python 在ubuntu服务器上,nginx无法提供跨域图像url,python,django,nginx,Python,Django,Nginx,我使用Django框架开发了这个项目,并从中获取图像文件 在localhost中,我已经测试并能够获得我的列表页面中的所有图像,但在具有域http://www.myfirstsite.org&我无法获取托管在http://data.myothersite.org和获取权限被拒绝错误 我已尝试设置add_头访问控制允许原点http://data.myothersite.org/`在nginx conf文件中,但没有任何运气 我也试图在网上找到解决方案,但没能找到 谢谢。因为您想在http://ww

我使用Django框架开发了这个项目,并从中获取图像文件

在localhost中,我已经测试并能够获得我的列表页面中的所有图像,但在具有域
http://www.myfirstsite.org
&我无法获取托管在
http://data.myothersite.org
和获取权限被拒绝错误

我已尝试设置
add_头访问控制允许原点
http://data.myothersite.org/`在nginx conf文件中,但没有任何运气

我也试图在网上找到解决方案,但没能找到


谢谢。

因为您想在
http://www.myfirstsite.org
from
http://data.myothersite.org
,您必须在
http://data.myothersite.org
而不是在
http://www.myfirstsite.org

add_header 'Access-Control-Allow-Origin' 'http://www.myfirstsite.org' always;
在nginx conf的
http://data.myothersite.org

add_header 'Access-Control-Allow-Origin' 'http://www.myfirstsite.org' always;

参考:

图像本身(即
标签)不受ACAO约束;你是如何检索的?你的代码是什么?你能直接在浏览器中查看图像吗?被拒绝的访问是否来自data.myothersite.org?也许只是文件系统权限?