28 lines
819 B
TypeScript
28 lines
819 B
TypeScript
import path from "node:path"
|
|
import react from "@vitejs/plugin-react"
|
|
import { defineConfig, loadEnv } from "vite"
|
|
|
|
// dev 서버: '/api' 요청을 backend(VITE_DEV_API_TARGET)로 proxy 해서
|
|
// 프론트와 같은 origin으로 보이게 함. httpOnly 쿠키 인증이 깔끔하게 동작.
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "")
|
|
const target = env.VITE_DEV_API_TARGET || "http://localhost:8001"
|
|
return {
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: { "@": path.resolve(__dirname, "./src") },
|
|
},
|
|
server: {
|
|
port: 15173,
|
|
proxy: {
|
|
"/api": {
|
|
target,
|
|
changeOrigin: true,
|
|
// 쿠키 그대로 전달
|
|
cookieDomainRewrite: { "*": "" },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|