我在我的React网站中使用访存。因此,服务器向我发送了一个set-cookie,
set-cookie: sessionid=8pw2k1il82a7ecsqomouww1j9dt3i20f; HttpOnly; Path=/; SameSite=None; Secure
因此,现在我想将其作为cookie发送到我的请求标头中。 我对此很陌生,因此在如何生成csrf令牌时遇到了麻烦。这是我要Cookie请求标头的函数。
return fetch(`${process.env.REACT_APP_BASEURL}/api-auth/check-session/`, {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
});
}