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:
51
README.md
51
README.md
@@ -56,9 +56,58 @@ src/
|
||||
- `npm run build` - Builds the app for production
|
||||
- `npm run preview` - Preview the production build locally
|
||||
|
||||
### API Status Checking Scripts
|
||||
|
||||
- `npm run api:check` - Run basic API status check
|
||||
- `npm run api:check:extended` - Run extended API status check with reports
|
||||
- `npm run api:check:verbose` - Run extended check with verbose output
|
||||
- `npm run api:check:real` - Run extended check with real credentials
|
||||
|
||||
### Environment Configuration Scripts
|
||||
|
||||
- `npm run env:dev` - Configure for development environment (localhost:8000)
|
||||
- `npm run env:prod` - Configure for production environment (api.pennyzo.com)
|
||||
- `npm run env:show` - Show current environment configuration
|
||||
|
||||
## Environment Setup
|
||||
|
||||
The application supports different environments with automatic API URL configuration:
|
||||
|
||||
### Development Environment
|
||||
|
||||
```bash
|
||||
npm run env:dev
|
||||
```
|
||||
|
||||
- API URL: `http://localhost:8000`
|
||||
- Enables debug mode and verbose logging
|
||||
|
||||
### Production Environment
|
||||
|
||||
```bash
|
||||
npm run env:prod
|
||||
```
|
||||
|
||||
- API URL: `https://api.pennyzo.com/api/v1/general`
|
||||
- Optimized for production usage
|
||||
|
||||
### Manual Configuration
|
||||
|
||||
Create a `.env` file in the project root:
|
||||
|
||||
```env
|
||||
# Development
|
||||
VITE_API_BASE_URL=http://localhost:8000
|
||||
NODE_ENV=development
|
||||
|
||||
# Production
|
||||
VITE_API_BASE_URL=https://api.pennyzo.com/api/v1/general
|
||||
NODE_ENV=production
|
||||
```
|
||||
|
||||
## Backend Integration Guide
|
||||
|
||||
Base URL: `https://api.pennyzo.com/api/v1/general` (configurable via `VITE_API_BASE_URL`)
|
||||
Base URL: Automatically configured based on environment (configurable via `VITE_API_BASE_URL`)
|
||||
|
||||
- HTTP client: `src/lib/http.ts` (handles JSON, form, and auth header)
|
||||
- Auth state: `src/context/AuthContext.tsx` (stores JWT token, loads `auth/me`)
|
||||
|
||||
Reference in New Issue
Block a user