2026-07-13 08:59:13 +00:00
|
|
|
|
import { defineConfig, type ProxyOptions } from "vite";
|
2026-07-10 05:10:31 +00:00
|
|
|
|
import react from "@vitejs/plugin-react";
|
2026-07-09 03:45:28 +00:00
|
|
|
|
|
2026-07-13 08:59:13 +00:00
|
|
|
|
const proxy = {
|
|
|
|
|
|
// Live API -> gateway
|
|
|
|
|
|
"/api": {
|
|
|
|
|
|
target: "http://127.0.0.1:8888",
|
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
configure: (gateway) => {
|
|
|
|
|
|
// Browser -> Vite is same-origin. Do not forward that Origin to the
|
|
|
|
|
|
// private gateway, where it would be mistaken for a direct CORS call.
|
|
|
|
|
|
gateway.on("proxyReq", (request) => request.removeHeader("origin"));
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
// 頭像等公開物件(MinIO path-style)。nginx 未轉 /haixun-assets 時,
|
|
|
|
|
|
// 流量會落到 Vite;由此代轉,避免回 SPA HTML。
|
|
|
|
|
|
"/haixun-assets": {
|
|
|
|
|
|
target: "http://127.0.0.1:9000",
|
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
} satisfies Record<string, string | ProxyOptions>;
|
|
|
|
|
|
|
2026-07-09 03:45:28 +00:00
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
|
plugins: [react()],
|
2026-07-10 05:10:31 +00:00
|
|
|
|
server: {
|
|
|
|
|
|
host: "0.0.0.0",
|
|
|
|
|
|
port: 5173,
|
|
|
|
|
|
strictPort: false,
|
|
|
|
|
|
allowedHosts: ["threads-tool-dev.30cm.net", ".30cm.net"],
|
2026-07-13 08:59:13 +00:00
|
|
|
|
proxy,
|
2026-07-10 05:10:31 +00:00
|
|
|
|
},
|
|
|
|
|
|
preview: {
|
|
|
|
|
|
host: "0.0.0.0",
|
|
|
|
|
|
port: 4173,
|
|
|
|
|
|
allowedHosts: ["threads-tool-dev.30cm.net", ".30cm.net"],
|
2026-07-13 08:59:13 +00:00
|
|
|
|
proxy,
|
2026-07-10 05:10:31 +00:00
|
|
|
|
},
|
|
|
|
|
|
});
|