Răsfoiți Sursa

feat: 支持 nginx 子路径代理 /ads/

- vite.config.ts: 新增 base 配置,通过 BASE_PATH 环境变量控制
- main.tsx: BrowserRouter 使用 import.meta.env.BASE_URL 作为 basename
- 生产构建: BASE_PATH=/ads/ npm run build
- 本地开发: 默认 /,不受影响

nginx 新增配置:
  upstream playableads { server 127.0.0.1:3001; }
  location /ads/ { proxy_pass http://playableads/; }
guoziyun 3 săptămâni în urmă
părinte
comite
57c075e509

Fișier diff suprimat deoarece este prea mare
+ 1 - 1
platform/client/dist/assets/index-CEiuM9qw.js


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

@@ -4,8 +4,8 @@
     <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="/assets/index-CjzBYgHM.js"></script>
-    <link rel="stylesheet" crossorigin href="/assets/index-BRjdK5H3.css">
+    <script type="module" crossorigin src="/ads/assets/index-CEiuM9qw.js"></script>
+    <link rel="stylesheet" crossorigin href="/ads/assets/index-BRjdK5H3.css">
   </head>
   <body>
     <div id="root"></div>

+ 1 - 1
platform/client/src/main.tsx

@@ -6,7 +6,7 @@ import "./index.css";
 
 ReactDOM.createRoot(document.getElementById("root")!).render(
   <React.StrictMode>
-    <BrowserRouter>
+    <BrowserRouter basename={import.meta.env.BASE_URL.replace(/\/$/, "")}>
       <App />
     </BrowserRouter>
   </React.StrictMode>

+ 5 - 0
platform/client/vite.config.ts

@@ -1,7 +1,12 @@
 import { defineConfig } from "vite";
 import react from "@vitejs/plugin-react";
 
+// BASE_PATH: 生产环境通过 nginx /ads/ 子路径代理时设为 "/ads/"
+// 本地开发默认 "/",也可通过环境变量覆盖:BASE_PATH=/ads/ npm run dev
+const BASE = process.env.BASE_PATH || "/";
+
 export default defineConfig({
+  base: BASE,
   plugins: [react()],
   server: {
     port: 9527,

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff