I am working on ionic and am using Django with django-rest-framework as a backend. I tried sending to my server using $httpas follows:
$http({
url: url,
method: method,
data: {
// some data
}
}).success...
I also installed the following in my configuration:
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
I also tried ngCookiesbut $cookies.csrftokenreturns nothing.
Here is my internal code:
class Mark(APIView):
def post(self, request):
return Response({
})
This works fine when I used the ion local server ionic serve, but when I create it on the iOS emulator or on my iPhone, csrf 403 appears:
{"detail":"CSRF Failed: CSRF token missing or incorrect."}
returned from the server.
Any idea on this? Thank you very much!