Convention: What is the correct pattern for making HTTP calls to backend...

Documentation for Sessions

📏 Convention: What is the correct pattern for making HTTP calls to backend...

Date: 2026-01-28
Time: 16:53:59 UTC
Session: editor2-72.81
Agent: backend
Confidence: 100%
Status: ✅ Documented


📋 Decision Context

Question:

What is the correct pattern for making HTTP calls to backend APIs in Angular services?

Task: Not specified


🎯 Decision Made

Chosen:

Inject API tokens from @libs-foundational/api-config. Pattern: 1) Import token: import { API_BASE_URL } from '@libs-foundational/api-config', 2) Inject in service: private readonly baseUrl = inject(API_BASE_URL), 3) Use in HTTP calls: this.http.get(${this.baseUrl}/endpoint). For AI API use AI_API_URL, for Docs API use DOCS_API_URL.

Options Considered:

  1. Use hardcoded relative URLs like /api/endpoint
  2. Use environment.backendApiUrl directly
  3. Inject API tokens from @libs-foundational/api-config

💭 Reasoning

Hardcoded /api URLs break in production because they resolve to the frontend domain (app.gograb.space/api) instead of the API domain (api.gograb.space/api). The tokens automatically use localhost in dev and production URLs when deployed. This was a critical bug fixed in Session 72.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation