docs: Frontend-Backend preferences 연동 진행 상황 업데이트
- 90% 완료 상태 - Gateway 라우팅, nginx 프록시, JWT 인증 모두 해결 - GET 요청 정상 작동 - PUT 요청 500 에러 디버깅 필요
This commit is contained in:
parent
7dea8c9c0f
commit
0fdf135867
@ -1,19 +1,23 @@
|
||||
# Frontend ActivityPanel과 Backend user_preferences 연동 불일치 문제
|
||||
# Frontend ActivityPanel과 Backend user_preferences 연동 구현
|
||||
|
||||
## 작성일: 2025-08-27
|
||||
## 작성자: happybell80
|
||||
## 상태: 🔴 미구현 - API 전혀 없음
|
||||
## 영향: 사용자 설정 기능 연동 불가
|
||||
## 최종 업데이트: 2025-08-27 20:30
|
||||
## 작성자: happybell80 / 51123 서버 관리자
|
||||
## 상태: 🟡 진행중 - Gateway 라우팅 추가 필요
|
||||
## 영향: 사용자 설정 기능 연동
|
||||
## 최종 업데이트: 2025-08-27 22:00
|
||||
|
||||
---
|
||||
|
||||
## 1. 핵심 문제
|
||||
## 1. 현재 상황
|
||||
|
||||
**API가 아예 구현되지 않음**
|
||||
- Frontend: localStorage만 사용, API 호출 코드 없음
|
||||
- Backend: preferences CRUD API 없음
|
||||
- Gateway: preferences 라우팅 없음
|
||||
### ✅ 완료된 작업
|
||||
- **Backend**: robeing-monitor에 preferences API 구현 (GET/PUT)
|
||||
- **Frontend**: localStorage → API 호출로 변경 완료
|
||||
- **배포**: robeing-monitor 51124:9024에서 실행 중
|
||||
|
||||
### 🔴 남은 문제
|
||||
- **Gateway 라우팅**: `/api/preferences`를 robeing-monitor로 프록시 안함
|
||||
- **현재**: 모든 `/api/*` 요청이 rb8001로만 감
|
||||
|
||||
---
|
||||
|
||||
@ -82,17 +86,22 @@ const scheduledTasks: ScheduledTask[] = [...]; // 하드코딩
|
||||
- 실제 데이터 조회 API 없음
|
||||
- conversation_logs 테이블 조회 엔드포인트 필요
|
||||
|
||||
### 3.4 API 라우팅 문제
|
||||
### 3.4 ✅ 해결됨: API 구현
|
||||
- **robeing-monitor**: preferences API 완전 구현
|
||||
- **GET /api/preferences/{user_id}**: 조회
|
||||
- **PUT /api/preferences/{user_id}**: 업데이트
|
||||
- **고정값 반환**: 미구현 필드는 기본값 제공
|
||||
|
||||
### 3.5 🔴 Gateway 라우팅 문제
|
||||
```python
|
||||
# robeing-gateway/main.py:391
|
||||
@app.api_route("/api/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
|
||||
# 모든 /api/* 요청을 가로챔
|
||||
# /api/preferences가 어디로 갈지 불명확
|
||||
# robeing-gateway/main.py:407
|
||||
@app.get("/api/{path:path}") # 모든 GET → rb8001로
|
||||
# /api/preferences도 rb8001로 가서 404 발생
|
||||
```
|
||||
|
||||
### 3.5 서버 위치 확인됨
|
||||
- PostgreSQL: 51123 서버만 (51124는 SSH 터널 사용)
|
||||
- robeing-monitor: 51124 서버 (포트 매핑 없음)
|
||||
**필요한 수정**:
|
||||
- `/api/preferences/*` → robeing-monitor(9024)로 프록시
|
||||
- JWT에서 UUID 추출하여 전달
|
||||
|
||||
### 3.6 실시간 동기화 부재
|
||||
- localStorage 기반으로 다른 디바이스와 동기화 안됨
|
||||
@ -158,25 +167,46 @@ const scheduledTasks: ScheduledTask[] = [...]; // 하드코딩
|
||||
|
||||
---
|
||||
|
||||
## 5. 검증 결과 (2025-08-27 20:30)
|
||||
## 5. 구현 현황 (2025-08-27 22:00)
|
||||
|
||||
### ✅ 작동 중
|
||||
- rb8001이 news_keywords로 맞춤 뉴스 제공
|
||||
- skill-email 토큰 자동 갱신 (Google 라이브러리 직접 사용)
|
||||
### ✅ 완료
|
||||
- **Backend API**: robeing-monitor에 구현 완료
|
||||
- **Frontend 수정**: API 호출 코드 추가, 자동 저장
|
||||
- **UI 처리**: 미구현 필드 비활성화 (opacity-50)
|
||||
- **배포**: 51124:9024 정상 작동
|
||||
|
||||
### ❌ 미구현
|
||||
- Frontend API 호출 코드
|
||||
- Backend preferences API
|
||||
- scheduled_tasks 테이블
|
||||
- email_filter 필드 사용
|
||||
### 🟡 진행중
|
||||
- **Gateway 라우팅**: preferences 전용 프록시 추가 필요
|
||||
|
||||
### ⚠️ 작동 방식
|
||||
- **현재**: Frontend → Gateway(8100) → rb8001 → 404
|
||||
- **필요**: Frontend → Gateway(8100) → robeing-monitor(9024)
|
||||
|
||||
---
|
||||
|
||||
## 6. 필수 구현 사항
|
||||
## 6. 아키텍처 상세
|
||||
|
||||
1. **Backend**: preferences CRUD API 구현 (robeing-monitor 또는 Gateway)
|
||||
2. **Frontend**: localStorage → API 호출로 변경
|
||||
3. **DB**: 다중 작업용 테이블 설계 (선택)
|
||||
### 데이터 흐름
|
||||
```
|
||||
Frontend (브라우저)
|
||||
↓
|
||||
[자동 저장 트리거]
|
||||
↓
|
||||
fetch('/api/preferences/{UUID}') # Gateway 경유
|
||||
↓
|
||||
Gateway (8100) + JWT 인증
|
||||
↓
|
||||
[라우팅 필요: preferences → 9024]
|
||||
↓
|
||||
robeing-monitor (9024)
|
||||
↓
|
||||
PostgreSQL user_preferences 테이블
|
||||
```
|
||||
|
||||
### UUID 체계
|
||||
- **JWT sub**: UUID (1e16e9d5-59f3-54da-a661-8abeabff4230)
|
||||
- **localStorage**: user_id에 UUID 저장
|
||||
- **API 경로**: `/api/preferences/{UUID}`
|
||||
|
||||
---
|
||||
|
||||
@ -195,13 +225,79 @@ const scheduledTasks: ScheduledTask[] = [...]; // 하드코딩
|
||||
|
||||
---
|
||||
|
||||
## 8. 결론
|
||||
## 8. Gateway 라우팅 추가 코드
|
||||
|
||||
**Frontend와 Backend 연결을 위한 API가 전혀 없음**
|
||||
- 즉시 사용 불가
|
||||
- 최소 API 구현 필요
|
||||
```python
|
||||
# /robeing-gateway/app/main.py (line 407 앞에 추가)
|
||||
@app.api_route("/api/preferences/{path:path}", methods=["GET", "PUT"])
|
||||
async def proxy_preferences(
|
||||
path: str,
|
||||
request: Request,
|
||||
x_user_id: str = Depends(get_verified_user)
|
||||
):
|
||||
"""Proxy preferences to robeing-monitor"""
|
||||
monitor_url = "http://192.168.219.52:9024"
|
||||
full_path = f"/api/preferences/{path}"
|
||||
|
||||
if request.method == "GET":
|
||||
response = await http_client.get(f"{monitor_url}{full_path}")
|
||||
elif request.method == "PUT":
|
||||
body = await request.json()
|
||||
response = await http_client.put(
|
||||
f"{monitor_url}{full_path}",
|
||||
json=body,
|
||||
headers={"X-User-Id": x_user_id}
|
||||
)
|
||||
|
||||
return response.json() if response.status_code == 200 else {"error": "Failed"}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*최종 수정: 2025-08-27 20:30*
|
||||
*상태: API 미구현으로 연동 불가*
|
||||
## 9. 결론
|
||||
|
||||
**90% 완료 - PUT 요청 500 에러 해결 필요**
|
||||
- Backend API ✅
|
||||
- Frontend 수정 ✅
|
||||
- Gateway 라우팅 ✅
|
||||
- nginx 프록시 ✅ (/gateway/ 사용)
|
||||
- JWT 인증 ✅
|
||||
- GET 요청 ✅ (200 OK)
|
||||
- PUT 요청 ❌ (500 에러 - robeing-monitor 문제)
|
||||
|
||||
---
|
||||
|
||||
## 10. 구현 과정 (2025-08-27)
|
||||
|
||||
### Phase 1: Backend API 구현 (20:00)
|
||||
- robeing-monitor에 preferences API 추가
|
||||
- 기존 컬럼만 사용 (news_keywords, briefing_time)
|
||||
- 확장 필드는 고정값 반환
|
||||
|
||||
### Phase 2: Frontend 수정 (21:00)
|
||||
- localStorage → API 호출 변경
|
||||
- 자동 저장 방식 구현
|
||||
- 미구현 필드 UI 비활성화
|
||||
|
||||
### Phase 3: Gateway 라우팅 (22:00)
|
||||
- preferences 전용 라우팅 추가
|
||||
- robeing-monitor(9024)로 프록시
|
||||
|
||||
### Phase 4: 경로 문제 해결 (22:30)
|
||||
- ❌ 처음: 직접 호출 (http://192.168.219.52:9024) - Mixed Content 에러
|
||||
- ❌ 다음: /api/preferences - nginx가 frontend-base(8000)로 전달
|
||||
- ✅ 해결: /gateway/api/preferences - Gateway(8100) 경유
|
||||
|
||||
### Phase 5: JWT 인증 추가 (22:40)
|
||||
- Frontend에서 Authorization 헤더 누락 발견
|
||||
- localStorage의 'token' || 'auth_token' 사용
|
||||
- Bearer 토큰 형식으로 전달
|
||||
|
||||
### 현재 상태 (22:45)
|
||||
- GET /api/preferences/{user_id}: 200 OK ✅
|
||||
- PUT /api/preferences/{user_id}: 500 에러 (robeing-monitor 내부 문제)
|
||||
|
||||
---
|
||||
|
||||
*최종 수정: 2025-08-27 22:45*
|
||||
*상태: robeing-monitor PUT 처리 디버깅 필요*
|
||||
Loading…
x
Reference in New Issue
Block a user