Bugfix: Why is AI chat and other AI features broken in production (a...

Documentation for Sessions

🐛 Bugfix: Why is AI chat and other AI features broken in production (a...

Date: 2026-02-16
Time: 21:34:48 UTC
Session: gspace1-110.2
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

Why is AI chat and other AI features broken in production (app.gograb.space)?

Task: Session 110: Production Readiness - Fix broken AI features in production


🎯 Decision Made

Chosen:

Fix 60+ hardcoded relative URLs (/ai-api/*) across libs/libs-ai/ to use injected AI_API_URL token. Create VITTO_API_URL token. Update CORS ALLOWED_ORIGINS. Fix Vitto domain inconsistency.

Options Considered:

  1. Fix individual URLs one by one
  2. Create centralized AI HTTP client wrapper service
  3. Use Angular HTTP interceptor to rewrite URLs
  4. Inject AI_API_URL token directly in each service (chosen)

💭 Reasoning

Root cause: 60+ files in libs/libs-ai/ use hardcoded relative URLs like '/ai-api/chat'. In development, Angular's proxy.conf.json rewrites these to http://localhost:3001/ai-api/chat. In production on Cloudflare Pages (static hosting), there is NO proxy - these requests hit the frontend server and 404. The fix uses the existing AI_API_URL InjectionToken from @libs-foundational/api-config which has a smart factory: returns localhost in dev, https://ai-api.gograb.space/ai-api in production. Also created VITTO_API_URL token for backend-vitto-api URLs. Additionally, CORS ALLOWED_ORIGINS was missing admin.gograb.space, dev.gograb.space, ai.gograb.space, space-admin.gograb.space, docs.gograb.space.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation