Convention: What is the correct pattern for environment-based API config...

Documentation for Sessions

📏 Convention: What is the correct pattern for environment-based API config...

Date: 2026-02-05
Time: 03:50:27 UTC
Session: editor2-89.5
Agent: backend
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

What is the correct pattern for environment-based API configuration in frontend apps?

Task: Document gograb-space environment pattern for reuse in other apps


🎯 Decision Made

Chosen:

Use environment.shared.ts with useMockApi flag for conditional interceptors

Options Considered:

  1. Hardcode URLs in each app
  2. Use ENVIRONMENT_PRESETS from api-config
  3. Use environment.shared.ts with useMockApi flag for conditional interceptors

💭 Reasoning

gograb-space provides the canonical pattern: (1) environment.shared.ts exports BACKEND_URLS, AI_API_URLS, DOCS_API_URLS with .railway/.local/.mock options, (2) environment.ts imports shared config and sets useMockApi boolean + specific URL selections, (3) app.config.ts uses environment.useMockApi to conditionally include mockHttpInterceptor, (4) provideApiConfigWithMock() handles API_BASE_URL injection based on environment. This allows: switching between mock/local/production by changing one flag, offline-first development without backend, seamless transition to production. gograb-admin and gograb-dev should adopt this pattern for consistency.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation