From 4ccda8ad49daca34cbc579068515a27aa6507a68 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 17 Sep 2025 21:40:43 -0400 Subject: [PATCH] Update vite config for new dashboard server location --- ecosystem.config.js | 222 --------------------------------------- inventory/vite.config.ts | 22 ++-- 2 files changed, 12 insertions(+), 232 deletions(-) delete mode 100644 ecosystem.config.js diff --git a/ecosystem.config.js b/ecosystem.config.js deleted file mode 100644 index 1f4881d..0000000 --- a/ecosystem.config.js +++ /dev/null @@ -1,222 +0,0 @@ -// ecosystem.config.js -const path = require('path'); -const dotenv = require('dotenv'); - -// Load environment variables safely with error handling -const loadEnvFile = (envPath) => { - try { - console.log('Loading env from:', envPath); - const result = dotenv.config({ path: envPath }); - if (result.error) { - console.warn(`Warning: .env file not found or invalid at ${envPath}:`, result.error.message); - return {}; - } - console.log('Env variables loaded from', envPath, ':', Object.keys(result.parsed || {})); - return result.parsed || {}; - } catch (error) { - console.warn(`Warning: Error loading .env file at ${envPath}:`, error.message); - return {}; - } -} - -// Load environment variables for each server -const authEnv = loadEnvFile(path.resolve(__dirname, 'dashboard/auth-server/.env')); -const aircallEnv = loadEnvFile(path.resolve(__dirname, 'dashboard/aircall-server/.env')); -const klaviyoEnv = loadEnvFile(path.resolve(__dirname, 'dashboard/klaviyo-server/.env')); -const metaEnv = loadEnvFile(path.resolve(__dirname, 'dashboard/meta-server/.env')); -const googleAnalyticsEnv = require('dotenv').config({ - path: path.resolve(__dirname, 'dashboard/google-server/.env') -}).parsed || {}; -const typeformEnv = loadEnvFile(path.resolve(__dirname, 'dashboard/typeform-server/.env')); -const inventoryEnv = loadEnvFile(path.resolve(__dirname, 'inventory/.env')); - -// Common log settings for all apps -const logSettings = { - log_rotate: true, - max_size: '10M', - retain: '10', - log_date_format: 'YYYY-MM-DD HH:mm:ss' -}; - -// Common app settings -const commonSettings = { - instances: 1, - exec_mode: 'fork', - autorestart: true, - watch: false, - max_memory_restart: '1G', - time: true, - ...logSettings, - ignore_watch: [ - 'node_modules', - 'logs', - '.git', - '*.log' - ], - min_uptime: 5000, - max_restarts: 5, - restart_delay: 4000, - listen_timeout: 50000, - kill_timeout: 5000, - node_args: '--max-old-space-size=1536' -}; - -module.exports = { - apps: [ - { - ...commonSettings, - name: 'auth-server', - script: './dashboard/auth-server/index.js', - env: { - NODE_ENV: 'production', - PORT: 3003, - ...authEnv - }, - error_file: 'dashboard/auth-server/logs/pm2/err.log', - out_file: 'dashboard/auth-server/logs/pm2/out.log', - log_file: 'dashboard/auth-server/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - PORT: 3003 - }, - env_development: { - NODE_ENV: 'development', - PORT: 3003 - } - }, - { - ...commonSettings, - name: 'aircall-server', - script: './dashboard/aircall-server/server.js', - env: { - NODE_ENV: 'production', - AIRCALL_PORT: 3002, - ...aircallEnv - }, - error_file: 'dashboard/aircall-server/logs/pm2/err.log', - out_file: 'dashboard/aircall-server/logs/pm2/out.log', - log_file: 'dashboard/aircall-server/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - AIRCALL_PORT: 3002 - } - }, - { - ...commonSettings, - name: 'klaviyo-server', - script: './dashboard/klaviyo-server/server.js', - env: { - NODE_ENV: 'production', - KLAVIYO_PORT: 3004, - ...klaviyoEnv - }, - error_file: 'dashboard/klaviyo-server/logs/pm2/err.log', - out_file: 'dashboard/klaviyo-server/logs/pm2/out.log', - log_file: 'dashboard/klaviyo-server/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - KLAVIYO_PORT: 3004 - } - }, - { - ...commonSettings, - name: 'meta-server', - script: './dashboard/meta-server/server.js', - env: { - NODE_ENV: 'production', - PORT: 3005, - ...metaEnv - }, - error_file: 'dashboard/meta-server/logs/pm2/err.log', - out_file: 'dashboard/meta-server/logs/pm2/out.log', - log_file: 'dashboard/meta-server/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - PORT: 3005 - } - }, - { - name: "gorgias-server", - script: "./dashboard/gorgias-server/server.js", - env: { - NODE_ENV: "development", - PORT: 3006 - }, - env_production: { - NODE_ENV: "production", - PORT: 3006 - }, - error_file: "dashboard/logs/gorgias-server-error.log", - out_file: "dashboard/logs/gorgias-server-out.log", - log_file: "dashboard/logs/gorgias-server-combined.log", - time: true - }, - { - ...commonSettings, - name: 'google-server', - script: path.resolve(__dirname, 'dashboard/google-server/server.js'), - watch: false, - env: { - NODE_ENV: 'production', - GOOGLE_ANALYTICS_PORT: 3007, - ...googleAnalyticsEnv - }, - error_file: path.resolve(__dirname, 'dashboard/google-server/logs/pm2/err.log'), - out_file: path.resolve(__dirname, 'dashboard/google-server/logs/pm2/out.log'), - log_file: path.resolve(__dirname, 'dashboard/google-server/logs/pm2/combined.log'), - env_production: { - NODE_ENV: 'production', - GOOGLE_ANALYTICS_PORT: 3007 - } - }, - { - ...commonSettings, - name: 'typeform-server', - script: './dashboard/typeform-server/server.js', - env: { - NODE_ENV: 'production', - TYPEFORM_PORT: 3008, - ...typeformEnv - }, - error_file: 'dashboard/typeform-server/logs/pm2/err.log', - out_file: 'dashboard/typeform-server/logs/pm2/out.log', - log_file: 'dashboard/typeform-server/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - TYPEFORM_PORT: 3008 - } - }, - { - ...commonSettings, - name: 'inventory-server', - script: './inventory/src/server.js', - env: { - NODE_ENV: 'production', - PORT: 3010, - ...inventoryEnv - }, - error_file: 'inventory/logs/pm2/err.log', - out_file: 'inventory/logs/pm2/out.log', - log_file: 'inventory/logs/pm2/combined.log', - env_production: { - NODE_ENV: 'production', - PORT: 3010, - ...inventoryEnv - } - }, - { - ...commonSettings, - name: 'new-auth-server', - script: './inventory-server/auth/server.js', - env: { - NODE_ENV: 'production', - AUTH_PORT: 3011, - ...inventoryEnv, - JWT_SECRET: process.env.JWT_SECRET - }, - error_file: 'inventory-server/auth/logs/pm2/err.log', - out_file: 'inventory-server/auth/logs/pm2/out.log', - log_file: 'inventory-server/auth/logs/pm2/combined.log' - } - ] -}; diff --git a/inventory/vite.config.ts b/inventory/vite.config.ts index cba754a..06936c0 100644 --- a/inventory/vite.config.ts +++ b/inventory/vite.config.ts @@ -45,49 +45,51 @@ export default defineConfig(({ mode }) => { port: 5175, proxy: { "/api/aircall": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/klaviyo": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/meta": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/gorgias": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/dashboard-analytics": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, - rewrite: (path) => path.replace("/api/dashboard-analytics", "/api/analytics"), + cookieDomainRewrite: { + "inventory.kent.pw": "localhost" + }, }, "/api/typeform": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/acot": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, }, "/api/clarity": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, rewrite: (path) => path, @@ -128,7 +130,7 @@ export default defineConfig(({ mode }) => { }, }, "/dashboard-auth": { - target: "https://dashboard.kent.pw", + target: "https://inventory.kent.pw", changeOrigin: true, secure: false, ws: true,