Files
EventHubFrontAdmin/vite.config.ts

64 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig(({ mode }) => {
// Режим прямого подключения к одиночной ноде (dev-direct)
if (mode === 'development.direct') {
return {
plugins: [react()],
server: {
port: 5173,
proxy: {
'/v1': 'http://localhost:8080',
'/api': {
target: 'http://localhost:8445', // возвращаемся к порту 8445
changeOrigin: true,
// rewrite больше не нужен, т.к. на 8445 уже правильный путь /admin/users
},
'/ws': {
target: 'ws://localhost:8446',
ws: true,
},
},
},
};
}
// Режим разработки через Traefik (кластер, dev)
if (mode === 'development') {
return {
plugins: [react()],
server: {
port: 5173,
proxy: {
'/v1': {
target: 'https://localhost',
changeOrigin: true,
secure: false,
headers: {
Host: 'admin-api.eventhub.local',
},
},
'/api': {
target: 'https://localhost',
changeOrigin: true,
secure: false,
headers: {
Host: 'admin-api.eventhub.local',
},
rewrite: (path) => path.replace(/^\/api/, '/api/admin'),
},
'/ws': {
target: 'wss://localhost',
ws: true,
},
},
},
};
}
// Production (сборка) прокси не используется, запросы идут через Nginx/Docker
return {
plugins: [react()],
};
});