Skip to content

Fix hardcoded API URLs breaking local development - #11

Merged
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-246b387c-31c0-47a6-8443-d682711431ec
Feb 11, 2026
Merged

Fix hardcoded API URLs breaking local development#11
pmca31 merged 4 commits into
build-octofit-appfrom
copilot/sub-pr-2-246b387c-31c0-47a6-8443-d682711431ec

Conversation

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

All frontend components hardcoded API URLs using https://${process.env.REACT_APP_CODESPACE_NAME}-8000.app.github.dev, causing "undefined" in URLs when the environment variable is unset during local development.

Changes

  • Centralized API configuration (src/config/api.js)

    • Priority: REACT_APP_API_BASE_URLREACT_APP_CODESPACE_NAMEhttp://localhost:8000
    • Exports getApiUrl(endpoint) helper for consistent URL construction
  • Component updates

    • Replaced hardcoded URL templates in Activities, Users, Workouts, Leaderboard, and Teams
    • All API calls now use getApiUrl('/api/endpoint/')
  • Documentation

    • Updated .env.example with configuration options
    • Added API_CONFIG.md with usage examples

Example

// 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/');

Environment variable priority enables custom backend URLs via REACT_APP_API_BASE_URL while maintaining Codespaces compatibility and providing localhost fallback.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 11, 2026 19:30
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 Fix hardcoded API URLs breaking local development Feb 11, 2026
Copilot AI requested a review from pmca31 February 11, 2026 19:32
@pmca31
pmca31 marked this pull request as ready for review February 11, 2026 19:50
@pmca31
pmca31 merged commit 8c4fbb8 into build-octofit-app Feb 11, 2026
@pmca31
pmca31 deleted the copilot/sub-pr-2-246b387c-31c0-47a6-8443-d682711431ec branch February 11, 2026 19:51
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