| import { defineConfig } from 'vite' |
| import react from '@vitejs/plugin-react' |
| import { dirname, resolve } from 'node:path' |
| import { fileURLToPath } from 'node:url' |
|
|
| const webuiDir = dirname(fileURLToPath(import.meta.url)) |
| const repoRoot = resolve(webuiDir, '..') |
|
|
| export default defineConfig(({ mode }) => ({ |
| plugins: [ |
| react(), |
| ], |
| server: { |
| port: 5173, |
| fs: { |
| allow: [repoRoot], |
| }, |
| proxy: { |
| |
| '/admin': { |
| target: 'http://localhost:5001', |
| changeOrigin: true, |
| |
| bypass(req, res, proxyOptions) { |
| const url = req.url |
| |
| if (url === '/admin' || url === '/admin/' || url === '/admin?') { |
| console.log('[Vite Proxy] Bypass (page):', url) |
| return '/index.html' |
| } |
| |
| console.log('[Vite Proxy] Proxy to backend:', url) |
| |
| }, |
| }, |
| '/v1': { |
| target: 'http://localhost:5001', |
| changeOrigin: true, |
| }, |
| }, |
| }, |
| build: { |
| outDir: '../static/admin', |
| emptyOutDir: true, |
| }, |
| |
| base: mode === 'production' ? '/admin/' : '/', |
| })) |
|
|