[英]adding CSRF TOKEN in axios request
如何在我的 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 錯誤(禁止)。 我必須包含其他內容嗎?
授權: ${tokenApp}
可能需要:
授權: Bearer ${tokenApp}
但是,如果沒有關於服務器端的詳細信息、您使用的框架以及有關如何在服務器端實際設置身份驗證的一些信息,除了猜測之外,沒有辦法確定哪里出了問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.