XSRF
This commit is contained in:
@@ -9,6 +9,8 @@ const http = axios.create({
|
|||||||
"Content-Type": HTTP_CONTENT_TYPE.APPLICATION_JSON,
|
"Content-Type": HTTP_CONTENT_TYPE.APPLICATION_JSON,
|
||||||
},
|
},
|
||||||
baseURL: import.meta.env.VITE_API_URL,
|
baseURL: import.meta.env.VITE_API_URL,
|
||||||
|
xsrfCookieName: "csrftoken",
|
||||||
|
xsrfHeaderName: "X-XSRF-TOKEN",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置实例的原型
|
// 设置实例的原型
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import router from "@/router";
|
|||||||
import { getCsrfToken } from "./csrf";
|
import { getCsrfToken } from "./csrf";
|
||||||
|
|
||||||
export const downloadFile = (res: any) => {
|
export const downloadFile = (res: any) => {
|
||||||
const [, filename] = res.headers["content-disposition"]?.split(";");
|
const [, filename] = res.headers?.["content-disposition"]?.split(";") || [];
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.download = decodeURIComponent(
|
link.download = decodeURIComponent(
|
||||||
filename?.replace("filename=", "").replace(/\"/g, "").trim() || "",
|
filename?.replace("filename=", "").replace(/\"/g, "").trim() || "",
|
||||||
|
|||||||
Reference in New Issue
Block a user