37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
// Vignette web — Vite + React 19.
|
|
// 개발 시 /api, /auth 프록시로 FastAPI(8000) 백엔드에 붙는다.
|
|
// 쿠키 인증(__Host-vignette_sid)을 위해 changeOrigin + 쿠키 전달.
|
|
const nodeEnv = (
|
|
globalThis as unknown as {
|
|
process?: { env?: { VITE_ALLOWED_HOSTS?: string; VITE_API_PROXY_TARGET?: string } };
|
|
}
|
|
).process?.env;
|
|
const allowedHosts = (nodeEnv?.VITE_ALLOWED_HOSTS ?? "")
|
|
.split(",")
|
|
.map((host: string) => host.trim())
|
|
.filter(Boolean);
|
|
const apiProxyTarget = nodeEnv?.VITE_API_PROXY_TARGET?.trim() || "http://127.0.0.1:8000";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
port: 5173,
|
|
...(allowedHosts.length ? { allowedHosts } : {}),
|
|
proxy: {
|
|
"/api": {
|
|
target: apiProxyTarget,
|
|
changeOrigin: true,
|
|
ws: true,
|
|
// 백엔드 라우트는 /auth, /sessions, /health 로 노출되므로 /api 프리픽스 제거.
|
|
rewrite: (path) => path.replace(/^\/api/, ""),
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: "dist",
|
|
sourcemap: false,
|
|
},
|
|
});
|