0
votes

i developed a web api using djangorestframework but when i am consuming api using angularJS, browser shows error

XMLHttpRequest cannot load http://127.0.0.1:8000/webapi/orders. Response > to preflight request doesn't pass access control check: No 'Access- Control-Allow-Origin' header is present on the requested resource. Origin > 'http://127.0.0.1:37749' is therefore not allowed access.

  • angularJS app is hosted on 127.0.0.1:37749/ and
  • django api is hosted on 127.0.0.1:8000/

how to configure settings.py to solve this problem? please help!!!

1

1 Answers

0
votes

You are having an issue with Cross Origin Resource Sharing.

See http://www.django-rest-framework.org/topics/ajax-csrf-cors/#cors for solution. In particular django-cors-headers is what you'll want to fix that issue.