fixed missing env

This commit is contained in:
2ManyProjects 2025-04-26 00:41:04 -05:00
parent 797e9bac4f
commit 08bd77efb7
2 changed files with 52 additions and 40 deletions

View file

@ -256,6 +256,9 @@ module.exports = (pool, query, authMiddleware) => {
envContent += `DB_PASSWORD=${config.db.password}\n`;
envContent += `DB_NAME=${config.db.database}\n`;
envContent += `DB_PORT=${config.db.port}\n`;
envContent += `POSTGRES_USER=${config.db.user}\n`;
envContent += `POSTGRES_PASSWORD=${config.db.password}\n`;
envContent += `POSTGRES_DB=${config.db.database}\n`;
// Get site environment from settings or use existing config
const siteEnvSetting = allSettings.find(s => s.key === 'site_environment');

View file

@ -1,9 +1,20 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import dotenv from 'dotenv';
// https://vitejs.dev/config/
export default defineConfig({
export default defineConfig(({mode}) => {
// Load env variables
const env = loadEnv(mode, process.cwd(), '');
// Determine HMR host based on environment
const isProduction = process.env.ENVIRONMENT === "prod";
const hmrHost = isProduction ? 'rocks.2many.ca' : 'localhost';
const hmrConfig = isProduction
? { host: hmrHost }
: { host: hmrHost, clientPort: 3000 };
return {
plugins: [react()],
resolve: {
alias: {
@ -35,10 +46,7 @@ export default defineConfig({
watch: {
usePolling: true,
},
hmr: {
clientPort: 3000,
host: 'localhost',
}
hmr: hmrConfig
},
build: {
outDir: 'dist',
@ -46,4 +54,5 @@ export default defineConfig({
emptyOutDir: true,
sourcemap: process.env.NODE_ENV !== 'production'
}
}
});