Which browsers are you using.. it could probably be that cors is disabled
in your browser. Try switching on cors in your browser ...if you don't have
it as an extension just add it up


On Tue, 3 Apr 2018, 11:08 , <cont...@blissedmaths.com> wrote:

> 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
> <https://groups.google.com/d/msgid/django-users/a25fa6f4-4fe4-4abf-8f76-c766b23da74d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAG%2BabP8VZ2YiHwuPEwaNXFc%2BR%3DXpU4ZQru7yhRuhicyJ_h_DJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to