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,33 +1,32 @@
import { fileURLToPath, URL } from 'node:url' import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
//import vueDevTools from 'vite-plugin-vue-devtools'
import fs from 'fs' import fs from 'fs'
export default defineConfig({ export default defineConfig(({ mode }) => {
plugins: [vue() /*vueDevTools()*/], const env = loadEnv(mode, process.cwd(), '')
server: { const backendHost = env.VITE_BACKEND_HOST ?? '192.168.1.219'
host: '0.0.0.0',
https: { return {
key: fs.readFileSync('./192.168.1.102+1-key.pem'), plugins: [vue()],
cert: fs.readFileSync('./192.168.1.102+1.pem'), server: {
}, host: '0.0.0.0',
proxy: { https: {
'/api': { key: fs.readFileSync('./192.168.1.102+1-key.pem'),
target: 'http://192.168.1.219:5000', cert: fs.readFileSync('./192.168.1.102+1.pem'),
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, ''),
}, },
'/events': { proxy: {
target: 'http://192.168.1.219:5000', '/api': {
changeOrigin: true, target: `http://${backendHost}:5000`,
secure: false, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
}, },
}, },
}, resolve: {
resolve: { alias: {
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)),
'@': fileURLToPath(new URL('./src', import.meta.url)), },
}, },
}, }
}) })