cefense/apps/frontend/vite.config.ts
2026-08-18 19:38:47 +05:30

27 lines
1 KiB
TypeScript

import { defineConfig } from 'vite'
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
import babel from '@rolldown/plugin-babel'
// Backend origin to proxy /auth and /api to in dev (default local backend).
const BACKEND = process.env.BACKEND_URL ?? 'http://localhost:3001'
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
babel({ presets: [reactCompilerPreset()] })
],
server: {
allowedHosts: ['.trycloudflare.com'],
// Same-origin proxy: the browser only ever talks to the Vite origin, so the
// session cookie stays first-party (works through tunnels too).
proxy: {
'/auth': { target: BACKEND, changeOrigin: true },
'/api': { target: BACKEND, changeOrigin: true },
'/health': { target: BACKEND, changeOrigin: true },
// Lets the Cloud Run scanner job reach the local backend's secret-guarded
// callback through the same tunnel (SCAN_CALLBACK_URL = the tunnel URL).
'/internal': { target: BACKEND, changeOrigin: true },
},
},
})