Files
ORCID2SWORD/frontend/vite.config.js
T

30 lines
869 B
JavaScript

import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
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,
allowedHosts: true,
port: 5173,
proxy: {
'/api': { target: proxyTarget, changeOrigin: true },
'/health': { target: proxyTarget, changeOrigin: true },
...(base !== '/' && {
[`${base}api`]: {
target: proxyTarget,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${base}api`), '/api')
}
}),
},
},
}
})