CSRF with Django, React+Redux using Axios

后端 未结 9 1266
南笙
南笙 2020-11-28 04:35

This is an educational project, not for production. I wasn\'t intending to have user logins as part of this.

Can I make POST calls to Django with a CSRF token withou

9条回答
  •  遥遥无期
    2020-11-28 05:22

    There is actually a really easy way to do this.

    Add axios.defaults.xsrfHeaderName = "X-CSRFToken"; to your app config and then set CSRF_COOKIE_NAME = "XSRF-TOKEN" in your settings.py file. Works like a charm.

提交回复
热议问题