如何使用whatwg-fetch库传递CSRF令牌

问题描述

我正在使用whatwg-fetch库,并且在发送403 Forbidden error请求时得到POST

这是错误

Forbidden (403)
CSRF verification Failed. Request aborted.

You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons,to ensure that your browser is not being hijacked by third parties.

If you have configured your browser to disable cookies,please re-enable them,at least for this site,or for 'same-origin' requests.

据我了解,我需要在发帖请求中发送CSRF令牌,问题是我不确定将其添加到何处。

我尝试将其添加标题中,如下所示:

headers: {
  'X-CSRF-Token': Cookies.get('csrftoken'),},

但这不起作用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)