Files
Arkie-Library-Frontend/vite.config.ts
thomas 769087ba4a
All checks were successful
Deploy to Frontend Servers / deploy (push) Successful in 53s
Route same-origin API via /apnew/api to bypass ALB /api* rule.
ALB sends /api/* to an unreachable backend target group (502 on apex).
Use VITE_API_PREFIX=/apnew with nginx proxy to backend-1 until the listener rule is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 17:56:38 +08:00

34 lines
994 B
TypeScript

import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const apiProxyTarget = env.DEV_API_PROXY_TARGET || "http://127.0.0.1:8080";
return {
plugins: [react()],
build: {
rollupOptions: {
output: {
// Entry script at site root (/index-[hash].js); lazy chunks + CSS stay under /assets/.
entryFileNames: "[name]-[hash].js",
chunkFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
},
server: {
port: 5173,
proxy: {
"/apnew/api": {
target: apiProxyTarget,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/apnew/, ""),
},
"/api": { target: apiProxyTarget, changeOrigin: true },
"/uploads": { target: apiProxyTarget, changeOrigin: true },
},
},
};
});