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:
@@ -1,3 +1,24 @@
|
||||
export const API_BASE_URL =
|
||||
(import.meta as any)?.env?.VITE_API_BASE_URL ||
|
||||
'https://api.pennyzo.com/api/v1/general';
|
||||
// Environment detection
|
||||
const isDevelopment = import.meta.env.DEV;
|
||||
const isProduction = import.meta.env.PROD;
|
||||
|
||||
// API Base URL configuration
|
||||
export const API_BASE_URL =
|
||||
import.meta.env.VITE_API_BASE_URL ||
|
||||
(isDevelopment ? 'http://localhost:8000' : 'https://api.pennyzo.com/api/v1/general');
|
||||
|
||||
// API Configuration
|
||||
export const API_CONFIG = {
|
||||
BASE_URL: API_BASE_URL,
|
||||
TIMEOUT: 30000, // 30 seconds
|
||||
RETRY_ATTEMPTS: 3,
|
||||
DEVELOPMENT_PORT: 8000,
|
||||
PRODUCTION_URL: 'https://api.pennyzo.com/api/v1/general'
|
||||
};
|
||||
|
||||
// Environment flags
|
||||
export const ENV = {
|
||||
isDevelopment,
|
||||
isProduction,
|
||||
mode: import.meta.env.MODE || 'development'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user