From 71947122bc277a2e2f14c77d87f4481e5a0138db Mon Sep 17 00:00:00 2001 From: dolphin <78075021@qq.com> Date: Wed, 24 Jan 2024 13:29:01 +0800 Subject: [PATCH] fix: download file --- src/frontend/src/util/utils.ts | 2 +- src/frontend/vite.config.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/util/utils.ts b/src/frontend/src/util/utils.ts index c80086745..8f7244e2a 100644 --- a/src/frontend/src/util/utils.ts +++ b/src/frontend/src/util/utils.ts @@ -8,7 +8,7 @@ export function classNames(...classes: Array): string { export function downloadFile(url, label) { axios.get(url, { responseType: "blob" }).then((res: any) => { - const blob = new Blob([res]); + const blob = new Blob([res.data], { type: res.headers['content-type'] }); const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = label; diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index 7a0add99a..6bf76bfd3 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -6,7 +6,6 @@ import svgr from "vite-plugin-svgr"; const apiRoutes = ["^/api/", "/health"]; // Use environment variable to determine the target. -//const target = process.env.VITE_PROXY_TARGET || "http://192.168.106.120:3002"; const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860"; const proxyTargets = apiRoutes.reduce((proxyObj, route) => { @@ -19,7 +18,7 @@ const proxyTargets = apiRoutes.reduce((proxyObj, route) => { }; // 文件服务地址 proxyObj['/bisheng'] = { - target: "http://110.16.193.170:50061", + target: "http://127.0.0.1", changeOrigin: true, withCredentials: true, secure: false