【发布时间】:2022-01-12 21:41:58
【问题描述】:
如何在我的axios请求中设置CSRF TOKEN,我试过了
// axios.defaults.xsrfCookieName = 'csrftoken';
// axios.defaults.xsrfHeaderName = 'X-XSRF-TOKEN';
const tokenApp = window.localStorage.getItem('token')
const { data: res } = await axios.post(`${URL}`, formData, {
withCredentials: true,
xsrfHeaderName: 'X-XSRF-TOKEN',
headers: {
Authorization: `${tokenApp}`,
"Content-Type": "multipart/form-data"
}
});
res.file = `http://20.88.238.192/azure-storage/api/blob/download/?file=${res.nameFile}`;
return res;
但我仍然收到 403 错误(禁止)。我必须包含其他内容吗?
【问题讨论】:
-
发送
FormData,do not manually set the content-type header时
标签: reactjs api axios csrf csrf-token