修复了上传种子bug

Change-Id: I8b48880bafb43632f20cf2f07b43096efe5bead0
diff --git a/.env.development b/.env.development
index bbed15d..8ecc252 100644
--- a/.env.development
+++ b/.env.development
@@ -1 +1,7 @@
-VUE_APP_API_BASE_URL=http://localhost:8081
\ No newline at end of file
+# .env.development  ——  只在开发环境生效
+
+# 给 axios 用:全部请求走 /api,相对路径即可触发 devServer 代理
+VUE_APP_BASE_API=/api
+
+# 给 devServer 代理用:本机后端地址(需要时可改成 Docker / VM IP)
+VUE_APP_BACKEND=http://localhost:8081
diff --git a/src/api/request.js b/src/api/request.js
index dd5aade..89419b8 100644
--- a/src/api/request.js
+++ b/src/api/request.js
@@ -5,10 +5,10 @@
 const request = axios.create({

   // 关键:不要设置baseURL,或者设置为空字符串

   // 这样请求会发送到当前域名(8080),然后被代理转发到8081

-  baseURL: '',

+  baseURL: process.env.VUE_APP_BASE_API || '/api',

   timeout: 10000,

   headers: {

-    'Content-Type': 'application/json'

+    // 'Content-Type': 'application/json'

   }

 })

 

diff --git a/src/api/torrent.js b/src/api/torrent.js
index 3c93697..f5df487 100644
--- a/src/api/torrent.js
+++ b/src/api/torrent.js
@@ -81,7 +81,7 @@
  */

 export function getTorrentDetail(infoHash) {

   return request({

-    url: `/api/torrent/${infoHash}`,

+    url: `/torrent/${infoHash}`,

     method: 'get'

   })

 }

@@ -93,7 +93,7 @@
  */

 export function getTorrents(params) {

   return request({

-    url: '/api/torrents',

+    url: '/torrents',

     method: 'get',

     params

   })

diff --git a/vue.config.js b/vue.config.js
index 7d53894..808123a 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,37 +1,40 @@
+// vue.config.js

 const { defineConfig } = require('@vue/cli-service')

 

 module.exports = defineConfig({

   transpileDependencies: true,

+

+  /*  dev 服务只跑在 8080;真正的后端地址改用

+      环境变量 VUE_APP_BACKEND,默认仍指向 8081  */

   devServer: {

     port: 8080,

     proxy: {

+      // ❶ 统一以 /api 开头的请求全部反向代理

       '/api': {

-        target: 'http://localhost:8081',

+        target: process.env.VUE_APP_BACKEND || 'http://localhost:8081',

         changeOrigin: true,

         ws: true,

         logLevel: 'debug'

       },

+

+      /* ❷ 可选:如果你项目里还有没改完的

+            /category、/torrent、/auth 旧写法,保留兼容性。

+            改完之后,把这一段删掉也行。 */

       '/category': {

-        target: 'http://localhost:8081',

+        target: process.env.VUE_APP_BACKEND || 'http://localhost:8081',

         changeOrigin: true,

-        pathRewrite: {

-          '^/category': '/api/category'

-        }

+        pathRewrite: { '^/category': '/api/category' }

       },

       '/torrent': {

-        target: 'http://localhost:8081',

+        target: process.env.VUE_APP_BACKEND || 'http://localhost:8081',

         changeOrigin: true,

-        pathRewrite: {

-          '^/torrent': '/api/torrent'

-        }

+        pathRewrite: { '^/torrent': '/api/torrent' }

       },

       '/auth': {

-        target: 'http://localhost:8081',

+        target: process.env.VUE_APP_BACKEND || 'http://localhost:8081',

         changeOrigin: true,

-        pathRewrite: {

-          '^/auth': '/api/auth'

-        }

+        pathRewrite: { '^/auth': '/api/auth' }

       }

     }

   }

-})
\ No newline at end of file
+})