Django Rest Framework / Angular JS Preview Options
My app is using DRF for backend and APIs using AngularJS. For some APIs, I am facing the following problem.
XMLHttpRequest cannot load `http://localhost:8000/someurl`. The request was redirected to `'http://localhost:8000/someurl/'`, which is disallowed for cross-origin requests that require preflight.
I am using django-cors-headers and I have provided my settings already.
- The Cors lineage is legal for everyone.
-
Append_slash
set to True. -
CORS_PREFLIGHT_MAX_AGE
... - The cors header middleware is installed accordingly.
Front End Server is running at localhost: 3000. Any help? Thank.
source to share
I think I have a reasonable solution to the problem. Perhaps someday it will be useful to others. AngularJS $ resource removes '/' from url. And the OPTIONS preprogram request for the url was 'http://localhost:8000/someURL'
redirected to 'http://localhost:8000/someURL/'
because django's APPENDS_SLASH is the default. Therefore, the request was redirected before the flight.
I need to force $ resource not to remove the '/' from the url or force django to APPEND_SLASH = False
and update urls accordingly.
source to share