The application uses a configurable API URL that can be set using environment variables.
In development mode, the application uses the proxy feature of Create React App to avoid CORS issues. This is configured in package.json with:
"proxy": "http://localhost:5000"This means API requests will be automatically proxied to http://localhost:5000 during development, and you don't need to specify the full URL in your API calls.
Note: The API endpoints are configured to use the /api/projects path, not just /projects. This matches the actual backend API structure.
For production deployment, you need to configure the API URL:
- Create a
.envfile in the root directory (you can copy from.env.example) - Set the
REACT_APP_API_BASE_URLvariable to your API server URL
Example:
REACT_APP_API_BASE_URL=https://api.example.com
If no environment variable is set, the application will default to /api as the API base URL in production.
The application uses a central configuration file (src/config.js) that:
- Detects whether the app is running in development or production mode
- In development: Uses relative URLs to leverage the proxy feature
- In production: Uses the configured API base URL from environment variables
API endpoints are defined in the config file:
const API_ENDPOINTS = {
projects: `${API_BASE_URL}/api/projects`,
};This approach allows you to:
- Develop locally without CORS issues
- Deploy to production with a configurable API URL
- Change the API URL without modifying the code