Browse Source

fix:文件下载跨域问题

chenjiaxin 2 tuần trước cách đây
mục cha
commit
6f07bbc7fd
1 tập tin đã thay đổi với 8 bổ sung1 xóa
  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;