Pattern: How should backend-to-backend HTTP clients construct URLs fo...
Documentation for Sessions
🎨 Pattern: How should backend-to-backend HTTP clients construct URLs fo...
Date: 2026-02-20
Time: 19:28:55 UTC
Session: gspace1-129.5
Agent: backend
Confidence: 100%
Status: ✅ Documented
📋 Decision Context
Question:
How should backend-to-backend HTTP clients construct URLs for backend-api endpoints?
Task: Document correct URL construction pattern for API clients
🎯 Decision Made
Chosen:
Use baseUrl = 'http://localhost:3000/api' (or from env BACKEND_API_URL) and append paths WITHOUT 'api/' prefix. Example: ${baseUrl}/users/hierarchy resolves to /api/users/hierarchy. Never do ${baseUrl}/api/... as that would produce /api/api/...
Options Considered:
- No alternatives documented
💭 Reasoning
The Vitto backend-api-client (backend-vitto-api/src/app/connectivity/backend-api-client.service.ts) correctly uses this pattern — baseUrl includes /api and all appended paths are relative. The Angular frontend uses the same pattern via API_BASE_URL injection token. E2E tests use a slightly different pattern: baseUrl = 'http://127.0.0.1:3000' (no /api) and prepend /api/ explicitly to paths. Both are correct as long as the /api segment appears exactly once in the final URL.
📁 Files Involved
apis/backend-vitto-api/src/app/connectivity/backend-api-client.service.tslibs/libs-foundational/core-angular/src/lib/services/backend-module-api.service.tslibs/libs-foundational/api-config/src/lib/api-tokens.ts
🔗 Related
- Decision ID:
dev_1771615735212_jyq0woo - Session: 129
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation