Fetch, set-cookies and csrf

前端 未结 2 1767
别那么骄傲
别那么骄傲 2020-12-18 06:45

I m using Isomorphic fetch in my application and I m having some troubles dealing with CSRF.

Actually, I m having a backend that sends me a CSRF-TOKEN in set-cookies

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 07:41

    Yes header name depends on your server. For example django usecase to setup CSRF token using fetch is like this:

      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json; charset=UTF-8',
        'X-CSRFToken': get_token
      },
    

提交回复
热议问题