浏览代码

fix: API 路径跟随 BASE_PATH 前缀

- api/client.ts: BASE 改为 import.meta.env.BASE_URL + 'api/v1'
- BuildHistory: 下载链接也使用 BASE_URL 前缀
- 修复 nginx /ads/ 代理下 API 请求 404 的问题
guoziyun 3 周之前
父节点
当前提交
fcc0330bce

文件差异内容过多而无法显示
+ 0 - 0
platform/client/dist/assets/index-CDHFlogp.js


+ 1 - 1
platform/client/dist/index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Playable Ads Platform</title>
-    <script type="module" crossorigin src="/ads/assets/index-CEiuM9qw.js"></script>
+    <script type="module" crossorigin src="/ads/assets/index-CDHFlogp.js"></script>
     <link rel="stylesheet" crossorigin href="/ads/assets/index-BRjdK5H3.css">
   </head>
   <body>

+ 1 - 1
platform/client/src/api/client.ts

@@ -1,4 +1,4 @@
-const BASE = "/api/v1";
+const BASE = `${import.meta.env.BASE_URL}api/v1`.replace(/\/+$/, "");
 
 async function request<T>(url: string, options?: RequestInit): Promise<T> {
   const res = await fetch(`${BASE}${url}`, {

+ 2 - 2
platform/client/src/components/BuildHistory.tsx

@@ -74,7 +74,7 @@ export default function BuildHistory({ creativeId, builds: initialBuilds, onUpda
                 {b.results.map((r) => (
                   <a
                     key={r.platform}
-                    href={`/api/v1/builds/${b.id}/download/${r.platform}`}
+                    href={`${import.meta.env.BASE_URL}api/v1/builds/${b.id}/download/${r.platform}`}
                     className={styles.downloadLink}
                     download
                   >
@@ -82,7 +82,7 @@ export default function BuildHistory({ creativeId, builds: initialBuilds, onUpda
                   </a>
                 ))}
                 <a
-                  href={`/api/v1/builds/${b.id}/download/all`}
+                  href={`${import.meta.env.BASE_URL}api/v1/builds/${b.id}/download/all`}
                   className={styles.downloadAll}
                   download
                 >

部分文件因为文件数量过多而无法显示