-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
26 lines (24 loc) · 915 Bytes
/
Copy pathvite.config.ts
File metadata and controls
26 lines (24 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// `/api/*` calls from the React app are proxied to the FastAPI backend so
// the dev experience matches a same-origin production deployment. Without
// this Vite serves `index.html` for `/api/*`, which the browser then tries
// to JSON.parse — producing "Unexpected token '<'".
//
// Override the target via env when needed:
// - Local (no Docker): defaults to http://localhost:8000.
// - docker-compose: set VITE_API_PROXY_TARGET=http://app:8000 (inside
// the compose network the backend hostname is `app`).
const API_PROXY_TARGET = process.env.VITE_API_PROXY_TARGET ?? 'http://localhost:8000'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api': {
target: API_PROXY_TARGET,
changeOrigin: true,
},
},
},
})