feat: update Vite configuration to load environment variables for backend host
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 1m1s

This commit is contained in:
2026-02-23 16:52:22 -05:00
parent 234adbe05f
commit a41a357f50

View File

@@ -1,11 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
//import vueDevTools from 'vite-plugin-vue-devtools'
import fs from 'fs'
export default defineConfig({
plugins: [vue() /*vueDevTools()*/],
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const backendHost = env.VITE_BACKEND_HOST ?? '192.168.1.219'
return {
plugins: [vue()],
server: {
host: '0.0.0.0',
https: {
@@ -14,14 +17,9 @@ export default defineConfig({
},
proxy: {
'/api': {
target: 'http://192.168.1.219:5000',
target: `http://${backendHost}:5000`,
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, ''),
},
'/events': {
target: 'http://192.168.1.219:5000',
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
@@ -30,4 +28,5 @@ export default defineConfig({
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
}
})