lee_fa
lee_fa

Reputation: 13

django-cors-middleware does not work

I've been trying django-cors-middleware for days, but I just cannot figure out how to set it up.
Can anyone tell me what I am doing wrong please?
Below is the test project setting I am using.



And that's it! That is every setting, and I ran server by

python manage.py runserver




Below is what I get by running above

(index):1 XMLHttpRequest cannot load https://www.google.co.jp/?gfe_rd=cr&ei=BuxgWJ-_LIyL8QfIgYe4BQ. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
(index):14 There was an error!

Upvotes: 1

Views: 955

Answers (1)

Alasdair
Alasdair

Reputation: 308779

The django-cors-middleware app allows you to control access to your Django app from different domains. It doesn't let you control access to google.co.jp from your Django app. You don't control the headers that google.co.jp returns, so you can't use the middleware to enable cors.

If the third party does not enable cors or jsonp, then you can't access it using javascript. You'll have to fetch the content in your view instead.

Upvotes: 1

Related Questions