Skip to content

Add centralized API configuration with localhost fallback - #7

Merged
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-one-more-time
Feb 11, 2026
Merged

Add centralized API configuration with localhost fallback#7
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-one-more-time

Conversation

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Frontend API calls were hard-coded to https://${REACT_APP_CODESPACE_NAME}-8000.app.github.dev, producing invalid URLs (https://undefined-8000...) when the environment variable was unset in local development.

Changes

  • Created src/config/api.js: Centralized API base URL resolution with fallback chain:

    1. REACT_APP_API_BASE_URL (explicit override)
    2. REACT_APP_CODESPACE_NAME (Codespaces)
    3. http://localhost:8000 (local default)
  • Updated all components: Replaced inline URL construction with getApiUrl() helper in Users, Workouts, Teams, Activities, and Leaderboard components

  • Updated .env.example: Documented both configuration options

Example

// Before
const apiUrl = `https://${process.env.REACT_APP_CODESPACE_NAME}-8000.app.github.dev/api/workouts/`;

// After
import { getApiUrl } from '../config/api';
const apiUrl = getApiUrl('/api/workouts/');

The getApiUrl() helper checks for codespaceName !== 'undefined' to prevent malformed URLs.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 11, 2026 19:24
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Copilot AI changed the title [WIP] Update registration validation and activities enhancement Add centralized API configuration with localhost fallback Feb 11, 2026
Copilot AI requested a review from pmca31 February 11, 2026 19:28
@pmca31
pmca31 marked this pull request as ready for review February 11, 2026 19:52
@pmca31
pmca31 merged commit 6cb79f8 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