XSRF headers not being set in AngularJS

前端 未结 5 1171
名媛妹妹
名媛妹妹 2020-12-10 05:38

I\'m developing a DJANGO + AngularJS application, where the angular part is not being served by django.

I set the angular $httpProvider as follows:

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 06:12

    I had a similar issue and it was embarrassingly my fault.

    My mistake:

    $.post('/url', data)
    

    Make sure you're using the $http object!

    $http.post('/url', data)
    

    It was very easy to make this mistake since both seem to work equally as well as each other, except former does not look at $http.defaults.headers.common['X-CSRFToken'], etc.

提交回复
热议问题