diff --git a/server/.env.example b/.env.example similarity index 100% rename from server/.env.example rename to .env.example diff --git a/docker-compose.yml b/docker-compose.yml index b39089289..fc6f7493b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: # You can change the host port (left side) if 7655 is already in use on your host - "7655:7655" env_file: - # Load environment variables from the .env file located in the server directory - - ./server/.env # Primary location + # Load environment variables from a .env file in the same directory as this compose file + - .env # Standard location # Optional: Define networks if needed, otherwise uses default bridge network # networks: # - pulse_network diff --git a/package.json b/package.json index 64293d76a..3a5882850 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "server/index.js", "scripts": { "start": "cd server && node index.js", - "dev:server": "NODE_ENV=development cd server && node index.js", + "dev:server": "NODE_ENV=development node -r dotenv/config --env-file=.env server/index.js", "dev:css": "tailwindcss -i ./src/index.css -o ./public/output.css --watch", "build:css": "tailwindcss -i ./src/index.css -o ./public/output.css --minify", "dev": "concurrently \"npm:dev:server\" \"npm:dev:css\"", diff --git a/server/index.js b/server/index.js index f05889e71..e7480fe6a 100644 --- a/server/index.js +++ b/server/index.js @@ -1,4 +1,4 @@ -require('dotenv').config(); // Load environment variables from .env file +// require('dotenv').config(); // Load environment variables from .env file // --- BEGIN Environment Variable Validation --- const primaryRequiredEnvVars = [ @@ -29,13 +29,13 @@ primaryRequiredEnvVars.forEach(varName => { if (missingVars.length > 0 || placeholderVars.length > 0) { console.error('\n--- Configuration Error (Primary Endpoint) ---'); if (missingVars.length > 0) { - console.error(`Missing required environment variables in server/.env for the primary endpoint: ${missingVars.join(', ')}`); + console.error(`Missing required environment variables: ${missingVars.join(', ')}. These are typically set via docker-compose.yml or a .env file.`); } if (placeholderVars.length > 0) { - console.error(`Primary environment variables seem to contain placeholder values in server/.env: ${placeholderVars.join(', ')}`); + console.error(`The following primary environment variables seem to contain placeholder values: ${placeholderVars.join(', ')}.`); } - console.error('Please ensure server/.env exists and contains valid Proxmox connection details for the primary endpoint.'); - console.error('Refer to server/.env.example for the required format.\n'); + console.error('Please ensure valid Proxmox connection details are provided via environment variables.'); + console.error('Refer to server/.env.example for the required variable names and format.\n'); process.exit(1); // Exit if primary configuration is invalid }