Files
Snip/vite.config.ts
2026-06-15 21:25:57 +07:00

26 lines
789 B
TypeScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// Minimal ambient declaration so we can read an env override without pulling in
// @types/node just for the config file.
declare const process: { env: Record<string, string | undefined> };
// In dev the SPA runs on :5173 while the Go API runs elsewhere (default :8080,
// or the compose gateway). Proxy /api so the browser stays same-origin — no
// CORS, and the session cookie works. Override the target with VITE_API_PROXY.
const apiTarget = process.env.VITE_API_PROXY || "http://localhost:8080";
export default defineConfig({
plugins: [react()],
server: {
host: true,
port: 5173,
proxy: {
"/api": {
target: apiTarget,
changeOrigin: true,
},
},
},
});