微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何使用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 举报,一经查实,本站将立刻删除。