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:
+9
-10
@@ -1,14 +1,13 @@
|
|||||||
import { StrictMode } from "react";
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from 'react-dom/client'
|
||||||
import { BrowserRouter } from "react-router-dom";
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
|
import App from './App.jsx'
|
||||||
|
import './index.css'
|
||||||
|
|
||||||
import "./index.css";
|
createRoot(document.getElementById('root')).render(
|
||||||
import App from "./App.jsx";
|
|
||||||
|
|
||||||
createRoot(document.getElementById("root")).render(
|
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<BrowserRouter>
|
<BrowserRouter basename={import.meta.env.BASE_URL}>
|
||||||
<App />
|
<App />
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</StrictMode>,
|
</StrictMode>
|
||||||
);
|
)
|
||||||
+4
-14
@@ -2,31 +2,21 @@ import { defineConfig, loadEnv } from 'vite'
|
|||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const env = loadEnv(mode, import.meta.dirname, '')
|
const env = loadEnv(mode, import.meta.dirname, '')
|
||||||
const proxyTarget = env.VITE_API_PROXY_TARGET || 'http://localhost:8000'
|
const proxyTarget = env.VITE_API_PROXY_TARGET || 'http://localhost:8000'
|
||||||
|
const base = env.VITE_BASE_PATH || '/'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
base,
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
server: {
|
server: {
|
||||||
host: true,
|
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,
|
allowedHosts: true,
|
||||||
port: 5173,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
// El backend agrupa todo bajo /api (researchers, export, …).
|
'/api': { target: proxyTarget, changeOrigin: true },
|
||||||
// Con un único prefijo evitamos tener que mantener una entrada
|
'/health': { target: proxyTarget, changeOrigin: true },
|
||||||
// por router cada vez que se añada un endpoint nuevo.
|
|
||||||
'/api': {
|
|
||||||
target: proxyTarget,
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/health': {
|
|
||||||
target: proxyTarget,
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user