TradingAgents/frontend/app
MarkLo127 ffc36edb97 Fix Railway ECONNREFUSED error by unifying backend URL resolution
Problem: Next.js frontend in production mode falls back to http://backend:8000
(Docker Compose internal hostname) when BACKEND_URL env var is not set.
In Railway's distributed environment, this hostname doesn't exist, causing
ECONNREFUSED errors.

Solution: Create unified getBackendUrl() function with consistent fallback
priority across all server-side proxying files:
1. Explicit BACKEND_URL (for Railway / custom deployment)
2. Development mode -> http://localhost:8000
3. NEXT_PUBLIC_API_URL (may be set in Railway)
4. Docker Compose default -> http://backend:8000

Changes:
- New: frontend/lib/backend-url.ts - centralized URL resolution
- Updated: frontend/next.config.ts - use getBackendUrl()
- Updated: frontend/app/api/chat/route.ts - use getBackendUrl()
- Updated: frontend/app/api/auth/google/token/route.ts - use getBackendUrl()

Railway users must set BACKEND_URL=https://<backend-service>.up.railway.app

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 11:03:05 +08:00
..
analysis 2026-03-10 17:58:38 +08:00
api Fix Railway ECONNREFUSED error by unifying backend URL resolution 2026-03-12 11:03:05 +08:00
auth/callback 2025-12-13 06:50:03 +08:00
history 2026-03-11 20:30:53 +08:00
apple-icon.png 2025-12-18 19:00:42 +08:00
apple-touch-icon-precomposed.png 2025-12-20 09:27:15 +08:00
apple-touch-icon.png 2025-12-18 19:00:42 +08:00
favicon.ico 2025-12-18 19:00:42 +08:00
favicon.png 2025-12-18 19:00:42 +08:00
globals.css 2026-03-10 18:58:03 +08:00
icon-192.png 2025-12-18 19:00:42 +08:00
icon-512.png 2025-12-18 19:00:42 +08:00
icon.png 2025-12-18 19:00:42 +08:00
layout.tsx 新增英文語系支援 2025-12-24 01:20:33 +08:00
manifest.json 2025-12-20 09:38:17 +08:00
page.tsx 新增英文語系支援 2025-12-24 01:20:33 +08:00