Bugfix: Why does docs URL always show production URL in local develo...

Documentation for Sessions

🐛 Bugfix: Why does docs URL always show production URL in local develo...

Date: 2026-02-09
Time: 22:17:26 UTC
Session: gspace1-101.7
Agent: backend
Confidence: 97%
Status: ✅ Documented


📋 Decision Context

Question:

Why does docs URL always show production URL in local development?

Task: Fix docs URL showing production URL in local development


🎯 Decision Made

Chosen:

Created resolveServiceUrl() utility that prioritizes NODE_ENV over env var, moved to @libs-api/api-viewer

Options Considered:

  1. Remove DOCS_API_BASE_URL from .env.local
  2. Invert priority: check NODE_ENV first
  3. Create reusable resolveServiceUrl utility

💭 Reasoning

The bug: .env.local had DOCS_API_BASE_URL=https://docs-api.gograb.space, and resolveDocsUrl() checked this FIRST before any environment detection. So it always returned the production URL even locally. Fix: created a reusable resolveServiceUrl(configGet, options) utility in @libs-api/api-viewer that checks NODE_ENV first — if not production, uses localhost:PORT; if production, reads from the env var with a hardcoded fallback. This pattern is now reusable by all 4 backends for cross-service URL resolution.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation