Update Vite configuration to use base path from environment and simplify proxy settings; adjust main entry point for BrowserRouter basename.

This commit is contained in:
Alexis
2026-05-13 11:30:12 +02:00
parent 2ccdcac4c8
commit 1e973bf81c
2 changed files with 14 additions and 25 deletions
+5 -15
View File
@@ -2,32 +2,22 @@ import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, import.meta.dirname, '')
const proxyTarget = env.VITE_API_PROXY_TARGET || 'http://localhost:8000'
const base = env.VITE_BASE_PATH || '/'
return {
base,
plugins: [react(), tailwindcss()],
server: {
host: true,
// Needed for HTTPS tunnels like ngrok during OAuth callback flows.
// We allow all hosts in dev to avoid host-blocking when ngrok URL rotates.
allowedHosts: true,
port: 5173,
proxy: {
// El backend agrupa todo bajo /api (researchers, export, …).
// Con un único prefijo evitamos tener que mantener una entrada
// por router cada vez que se añada un endpoint nuevo.
'/api': {
target: proxyTarget,
changeOrigin: true,
},
'/health': {
target: proxyTarget,
changeOrigin: true,
},
'/api': { target: proxyTarget, changeOrigin: true },
'/health': { target: proxyTarget, changeOrigin: true },
},
},
}
})
})