38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import react from '@vitejs/plugin-react'
|
|
import { defineConfig } from 'vite'
|
|
|
|
// Базовый путь приложения (оканчивается на '/'): ассеты и маршруты живут под /admin/.
|
|
// Задаётся при сборке: BASE_PATH=/panel/ npm run build или --build-arg BASE_PATH=/panel/
|
|
const basePath = process.env.BASE_PATH ?? '/admin/'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
base: basePath,
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
// Бэкенд не настраивает CORS, поэтому в dev всё идёт через прокси:
|
|
// API, авторизация (/oauth2/*) и OIDC discovery бэкенда.
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
},
|
|
'/oauth2': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
},
|
|
'/.well-known': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|