Skip to content

Add centralized API configuration with localhost fallback - #12

Merged
pmca31 merged 5 commits into
build-octofit-appfrom
copilot/sub-pr-2-741bb43a-a0ac-4d3c-b8ef-75364c55a593
Feb 11, 2026
Merged

Add centralized API configuration with localhost fallback#12
pmca31 merged 5 commits into
build-octofit-appfrom
copilot/sub-pr-2-741bb43a-a0ac-4d3c-b8ef-75364c55a593

Conversation

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Hard-coded API URLs using process.env.REACT_APP_CODESPACE_NAME broke local development with https://undefined-8000.app.github.dev/... when the env var was unset.

Changes

  • Created src/config/api.js: Centralized configuration with priority-based resolution:

    1. REACT_APP_API_BASE_URL (explicit URL, recommended)
    2. REACT_APP_CODESPACE_NAME (Codespaces, backward compatible)
    3. Default: http://localhost:8000
  • Updated all components to use getApiUrl(): Activities, Leaderboard, Teams, Users, Workouts

  • Environment configuration: Added REACT_APP_API_BASE_URL to .env and .env.example with documentation

  • Documentation: Updated FRONTEND_README.md with configuration examples for local, Codespaces, and production environments

Usage

import { getApiUrl } from './config/api';

const apiUrl = getApiUrl('/api/users/');
// Local dev: http://localhost:8000/api/users/
// Codespaces: https://{name}-8000.app.github.dev/api/users/

App now works locally without requiring environment variables.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 11, 2026 19:31
- Create config/api.js with getApiUrl utility
- Update all components to use centralized API config
- Add REACT_APP_API_BASE_URL env var support
- Maintain backward compatibility with REACT_APP_CODESPACE_NAME
- Update .env and .env.example with new configuration docs

Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
- Document REACT_APP_API_BASE_URL as recommended approach
- Explain configuration priority and fallback behavior
- Update setup instructions for local development
- Add examples for different environments

Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
When both REACT_APP_API_BASE_URL and REACT_APP_CODESPACE_NAME are set,
only the first is used due to priority. Commenting out the Codespaces
variable to make it clear that the localhost config is active.

Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on registration validation PR Add centralized API configuration with localhost fallback Feb 11, 2026
Copilot AI requested a review from pmca31 February 11, 2026 19:35
@pmca31
pmca31 marked this pull request as ready for review February 11, 2026 19:45
@pmca31
pmca31 merged commit 9e5fedb into build-octofit-app Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants