vite.config.js 880 B

123456789101112131415161718192021222324252627282930313233
  1. import { defineConfig, loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { fileURLToPath, URL } from 'node:url'
  4. export default defineConfig(({ mode }) => {
  5. const env = loadEnv(mode, process.cwd(), '')
  6. // In Docker the backend is reachable at http://backend:8000 via the pmdi_net network.
  7. // Override with VITE_API_TARGET env var for other environments.
  8. const apiTarget = env.VITE_API_TARGET || 'http://localhost:8000'
  9. return {
  10. plugins: [vue()],
  11. resolve: {
  12. alias: {
  13. '@': fileURLToPath(new URL('./src', import.meta.url)),
  14. },
  15. },
  16. server: {
  17. host: '0.0.0.0',
  18. port: 3000,
  19. proxy: {
  20. // Transparently forward all /api requests to the FastAPI backend
  21. '/api': {
  22. target: apiTarget,
  23. changeOrigin: true,
  24. secure: false,
  25. },
  26. },
  27. },
  28. }
  29. })