Django rest framework Reactjs sessions not working

前提是你 提交于 2019-12-08 15:16:28

I've found a solution in another stackoverflow question. This is the link to it.

By adding the following to my axios request, the code works successfully:

axios.get('some api url', {withCredentials: true});

So it seems my assumption about the cookie with the session id not being available to the frontend is incorrect.

I also found out that I could see the cookie by opening the web page in Chrome, then opening the developer tools > going to 'application' tab > click on cookies.

Here all the available cookies are listed, and also a sessionid cookie is shown.

I had the same issue, by adding withCredentials in axios call didn't solve my problem in django 2.2.3 and axios 0.19.0.

If the answer here doesn't work for you, then look into the below answer :)

React Django REST framework session is not persisting/working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!