prototype
This commit is contained in:
64
vite.config.ts
Normal file
64
vite.config.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
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()],
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user