Skip to content

Centralize API URL configuration with localhost fallback - #13

Merged
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-044f0a73-1df6-4ef4-90d2-c6738f3f4294
Feb 11, 2026
Merged

Centralize API URL configuration with localhost fallback#13
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-044f0a73-1df6-4ef4-90d2-c6738f3f4294

Conversation

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Hard-coded API URLs using process.env.REACT_APP_CODESPACE_NAME fail in local development, resulting in https://undefined-8000... when the environment variable is unset.

Changes

  • New centralized config (src/config/api.js):

    • Fallback priority: REACT_APP_API_BASE_URLREACT_APP_CODESPACE_NAMEhttp://localhost:8000
    • Exports getApiUrl() helper for consistent endpoint construction
  • Updated all components (Users, Teams, Activities, Leaderboard, Workouts):

    • Replaced inline URL construction with getApiUrl() imports
    • Removed direct environment variable access from components
// Before
const apiUrl = `https://${process.env.REACT_APP_CODESPACE_NAME}-8000.app.github.dev/api/users/`;

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

This ensures proper API connectivity across local development, GitHub Codespaces, and custom deployments without requiring environment-specific code changes in components.


✨ 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 2 commits February 11, 2026 19:33
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] Address feedback on registration validation and activities implementation Centralize API URL configuration with localhost fallback Feb 11, 2026
Copilot AI requested a review from pmca31 February 11, 2026 19:37
@pmca31
pmca31 marked this pull request as ready for review February 11, 2026 19:41
@pmca31
pmca31 merged commit aea3ff1 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