docs: Frontend-rb8001 채팅 엔드포인트 미연결 문제 추가

- 문제: Frontend /api/chat 요청이 rb8001에 도달 안 함
- 원인: rb8001에 /api/chat 엔드포인트 없음, Gateway 라우팅 누락
- 해결방안: 엔드포인트 추가 또는 Gateway 프록시 설정

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
happybell80 2025-08-26 13:51:02 +09:00
parent bb0e2715b6
commit cb2b0d814d

View File

@ -0,0 +1,191 @@
# Frontend-rb8001 대화 엔드포인트 미연결 문제
## 작성일: 2025-08-26
## 작성자: 서버 관리자
## 상태: 미해결
## 영향: Frontend(goeun2dc) 채팅 기능 완전 불가
---
## 1. 문제 상황
### 1.1 증상
- **사용자**: goeun2dc@gmail.com (happybell80)
- **현상**: Frontend 채팅 입력 시 응답 없음
- **경로**: Frontend(8000) → Gateway(8100) → ❌ (rb8001 도달 실패)
### 1.2 네트워크 플로우
```
[예상 플로우]
Frontend → Gateway(51123:8100) → rb8001(51124:8001)
[실제 플로우]
Frontend → Gateway(51123:8100) → 없음 (404)
```
---
## 2. 원인 분석
### 2.1 엔드포인트 불일치
| 구성요소 | 엔드포인트 | 상태 |
|---------|-----------|------|
| Frontend | `/api/chat` 요청 | 전송 중 |
| Gateway | 라우팅 규칙 없음 | ❌ |
| rb8001 | `/api/chat` 없음 | ❌ |
| rb8001 | `/complete` 있음 | ✅ (Slack용) |
### 2.2 서버별 확인 결과
#### 51123 서버 (Gateway)
```bash
# Gateway 환경변수
VITE_API_URL=http://localhost:8001 # 로컬 개발용
VITE_ROBING_API_URL=https://ro-being.com/gateway # 실제 사용 중
# Gateway 로그
JWT 인증 성공 (happybell80)
/api/chat 라우팅 규칙 없음
```
#### 51124 서버 (rb8001)
```bash
# rb8001 엔드포인트 확인
/complete - LLM 처리용 ✅
/api/slack/events - Slack 전용 ✅
/api/cron/daily-summary - 크론용 ✅
/api/chat - 없음 ❌
# 테스트 결과
curl http://localhost:8001/complete -d '{"prompt":"test"}' # 200 OK
curl http://localhost:8001/api/chat -d '{"message":"test"}' # 404 Not Found
```
### 2.3 근본 원인
1. **엔드포인트 미구현**: rb8001에 `/api/chat` 엔드포인트 없음
2. **Gateway 라우팅 누락**: Gateway가 rb8001로 프록시하지 않음
3. **프로토콜 불일치**: Frontend 요청 형식과 rb8001 `/complete` 형식 다름
---
## 3. 해결 방안
### 3.1 Option 1: rb8001에 /api/chat 엔드포인트 추가
```python
# rb8001/app/router/router.py
@router.post("/api/chat")
async def chat_endpoint(request: ChatRequest):
"""Frontend 채팅 요청 처리"""
# 1. Frontend 형식 → rb8001 형식 변환
# 2. _process_message() 호출
# 3. Frontend 형식으로 응답 반환
```
### 3.2 Option 2: Gateway에서 라우팅 매핑
```python
# robeing-gateway/app/main.py
@app.post("/api/chat")
async def proxy_chat(request: Request):
"""채팅 요청을 rb8001로 프록시"""
# 1. /api/chat → /complete 변환
# 2. http://192.168.219.52:8001/complete 호출
# 3. 응답 변환 후 반환
```
### 3.3 Option 3: Frontend 수정
```javascript
// frontend-customer/src/api/chat.js
// VITE_API_URL을 올바른 엔드포인트로 변경
const API_URL = import.meta.env.VITE_RB8001_URL || 'http://192.168.219.52:8001'
const endpoint = '/complete' // /api/chat 대신
```
---
## 4. 임시 해결책
### 즉시 적용 가능한 방법
```bash
# Gateway 컨테이너에 임시 프록시 추가
docker exec robeing-gateway bash -c "
cat > /tmp/proxy.py << 'EOF'
from fastapi import Request
import httpx
@app.post('/api/chat')
async def temp_proxy(request: Request):
data = await request.json()
async with httpx.AsyncClient() as client:
# 형식 변환
rb8001_data = {
'prompt': data.get('message', ''),
'user_id': data.get('user_id', 'web_user'),
'channel': 'web'
}
response = await client.post(
'http://192.168.219.52:8001/complete',
json=rb8001_data
)
return {'response': response.json().get('response', '')}
EOF
"
```
---
## 5. 검증 방법
### 5.1 엔드포인트 테스트
```bash
# Frontend 형식 테스트
curl -X POST http://localhost:8100/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "안녕하세요", "user_id": "happybell80"}'
# 예상 응답
{"response": "안녕하세요! 무엇을 도와드릴까요?"}
```
### 5.2 전체 플로우 테스트
1. Frontend 로그인 (goeun2dc@gmail.com)
2. 채팅 입력
3. rb8001 로그 확인: `docker logs rb8001 --tail 50`
4. 응답 수신 확인
---
## 6. 장기 해결 계획
### 6.1 아키텍처 정리
- Frontend ↔ rb8001 직접 통신 vs Gateway 경유 결정
- 통일된 API 규격 정의 (OpenAPI 스펙)
### 6.2 구현 우선순위
1. **긴급**: rb8001에 /api/chat 엔드포인트 추가
2. **중요**: Gateway 라우팅 규칙 정비
3. **일반**: Frontend 환경변수 정리
---
## 7. 관련 파일
### 51123 서버
- `/home/admin/robeing-gateway/app/main.py` - Gateway 라우팅
- `/home/admin/frontend-customer/.env` - Frontend 설정
### 51124 서버
- `/home/happybell/projects/ivada/rb8001/app/router/router.py` - rb8001 엔드포인트
- `/home/happybell/projects/ivada/rb8001/.env` - rb8001 설정
### 로컬 개발
- `frontend-customer/src/api/` - API 호출 코드
- `frontend-customer/src/components/Chat/` - 채팅 컴포넌트
---
## 8. 참고 사항
- Slack 채팅은 정상 작동 (별도 플로우)
- DM 기능도 정상 (/complete 직접 사용)
- 문제는 Web Frontend 채팅만 해당
- State Service는 rb8001에 통합됨 (250826_happybell80_rb8001_이중저장구현.md 참고)