Response in Console:-
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://blissedmaths.sgp1.digitaloceanspaces.com/media/topics/4276769703/4276769703.svg. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). I have user django-cors-headers, a Django App that adds CORS (Cross-Origin Resource Sharing) headers to responses. My setting.py file is CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_METHODS = ( 'DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT', ) CORS_ALLOW_HEADERS = ( 'accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with', ) MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware',] The image that is giving me error coming from Digital ocean space is <script> function fetchXML(url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.withCredentials = true; xhr.setRequestHeader('Access-Control-Allow-Origin' , '*'); console.log(xhr.getAllResponseHeaders) xhr.onreadystatechange = function (evt) { //Do not explicitly handle errors, those should be //visible via console output in the browser. if (xhr.readyState === 4) { callback(xhr.responseXML); } }; xhr.send(null); }; fetchXML("{{a.image.url}}",function(newSVGDoc) { //import it into the current DOM var n = document.importNode(newSVGDoc.documentElement,true); document.querySelector('.{{a.topic|slugify}}-image').appendChild(n); }); </script> This page is live at https://blissedmaths.com/myclassroom/polynomial/ I have added everything needed in setting.py by still header is not coming. I tries Jquery and AJAX also. But no use. How to fix this. *Is it requires some javascript also or only this backend is enough?* *I tried to add header via Nginx conf also. But didn't worked.* How can I solve this, by python code or by Jquery/JS or by server configuration files. No method worked for me actually. But image is coming from source. *Please provide a fix for this.* -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a25fa6f4-4fe4-4abf-8f76-c766b23da74d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.