Przeglądaj źródła

fix:文件下载跨域问题

chenjiaxin 2 tygodni temu
rodzic
commit
6f07bbc7fd
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      src/utils/downloadUtil.js

+ 8 - 1
src/utils/downloadUtil.js

@@ -17,7 +17,14 @@ export default {
         return false;
       }
 
-      const response = await fetch(url);
+      const response = await fetch(url, {
+        method: 'GET',
+        credentials: 'include', // 包含 cookies
+        headers: {
+          'Content-Type': 'application/json',
+        }
+      });
+      
       if (!response.ok) {
         Message.error('下载失败');
         return false;