Fix API endpoint configuration with environment-aware URLs

- Add environment-based API URL configuration (dev: localhost:8000, prod: api.pennyzo.com)
- Update PennyzoApiService to use centralized config with timeout settings
- Fix API status checker scripts to load .env variables using dotenv
- Add environment management scripts (set-env.ps1) with npm shortcuts
- Create comprehensive configuration testing and validation tools
- Add TypeScript definitions for Vite environment variables
- Update all documentation with new environment configuration instructions
- Install dotenv package for Node.js environment variable loading
- All APIs now correctly use environment-appropriate URLs automatically
This commit is contained in:
2025-09-25 14:40:20 +05:30
parent aece15a286
commit ebb7fcaac8
15 changed files with 742 additions and 11 deletions

View File

@@ -5,11 +5,18 @@
* and logs the results to the console.
*/
// Load environment variables from .env file
require('dotenv').config();
const axios = require('axios');
const chalk = require('chalk'); // For colorful console output
// Define the base URL
const BASE_URL = 'https://api.pennyzo.com/api/v1/general';
// Define the base URL based on environment
const BASE_URL = process.env.VITE_API_BASE_URL ||
process.env.API_BASE_URL ||
(process.env.NODE_ENV === 'production' ?
'https://api.pennyzo.com/api/v1/general' :
'http://localhost:8000');
// Test credentials (replace with actual test credentials if available)
const TEST_CREDENTIALS = {