Fix: Why do API calls fail with 'net::ERR_CONNECTION_REFUSED loca...

Documentation for Sessions

📝 Fix: Why do API calls fail with 'net::ERR_CONNECTION_REFUSED loca...

Date: 2026-01-28
Time: 16:54:13 UTC
Session: editor2-72.83
Agent: backend
Confidence: 100%
Status: ✅ Documented


📋 Decision Context

Question:

Why do API calls fail with 'net::ERR_CONNECTION_REFUSED localhost:3000' in production deployments?

Task: Not specified


🎯 Decision Made

Chosen:

Services using hardcoded /api URLs instead of injected tokens. In production, relative URLs like /api/endpoint resolve to the frontend domain (app.gograb.space/api) which doesn't exist. Solution: Replace all hardcoded API_BASE = '/api' with inject(API_BASE_URL) from @libs-foundational/api-config. The token provides the full URL (https://api.gograb.space/api in production, http://localhost:3000/api in dev).

Options Considered:

  1. Backend is down
  2. CORS misconfiguration
  3. Services using hardcoded /api URLs instead of injected tokens

💭 Reasoning

This was a critical production bug in Session 72. 11 files across libs-widgets, libs-module-utils, libs-structural, libs-ai, and libs-foundational had hardcoded /api URLs. All were fixed to use the API_BASE_URL injection token. Production builds now correctly call api.gograb.space instead of app.gograb.space.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation