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:
- Fix individual URLs one by one
- Create centralized AI HTTP client wrapper service
- Use Angular HTTP interceptor to rewrite URLs
- 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
libs/libs-ai/vitto-hub/src/lib/components/ai-panel/ai-panel.component.tslibs/libs-ai/vitto-hub/src/lib/services/space-agents.service.tslibs/libs-ai/gograb-ai-lib/src/lib/services/vitto-chat.service.tslibs/libs-ai/vitto-chat/src/lib/services/vitto-chat-engine.service.tslibs/libs-foundational/api-config/src/lib/api-tokens.tslibs/libs-foundational/api-config/src/index.tsdeployment/docs/ENV_LOCAL_TEMPLATE.mddocs/english/Deployment/RAILWAY-GITHUB-DEPLOYMENT.md
🔗 Related
- Decision ID:
dev_1771277685042_t7a2n2t - Session: 110
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation