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:
- Hardcode URLs in each app
- Use ENVIRONMENT_PRESETS from api-config
- 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
apps/gograb-space/src/environments/environment.tsapps/gograb-space/src/environments/environment.shared.tsapps/gograb-space/src/app/app.config.ts
🔗 Related
- Decision ID:
dev_1770263427632_zq9oyyk - Session: 89
- Workspace: editor2
Auto-generated by MCP Smart Consolidation