Files
sam-react-prod/claudedocs/api/[NEXT-2025-12-30] fetch-wrapper-session-context.md
byeongcheolryu d38b1242d7 feat: fetchWrapper 마이그레이션 및 토큰 리프레시 캐싱 구현
- 40+ actions.ts 파일을 fetchWrapper 패턴으로 마이그레이션
- 토큰 리프레시 캐싱 로직 추가 (refresh-token.ts)
- ApiErrorContext 추가로 전역 에러 처리 개선
- HR EmployeeForm 컴포넌트 개선
- 참조함(ReferenceBox) 기능 수정
- juil 테스트 URL 페이지 추가
- claudedocs 문서 업데이트

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 17:00:18 +09:00

2.5 KiB

ㅏ# 세션 요약 (2025-12-30)

완료된 작업

1. fetch-wrapper 목적 확인

  • 목적: 401 에러(세션 만료) 발생 시 로그인 리다이렉트를 중앙화
  • 장점: 중복 코드 제거 + 새 작업자도 규칙 준수 가능

2. Accounting 도메인 완료 (12/12)

  • SalesManagement/actions.ts
  • VendorManagement/actions.ts
  • PurchaseManagement/actions.ts
  • DepositManagement/actions.ts
  • WithdrawalManagement/actions.ts
  • VendorLedger/actions.ts
  • ReceivablesStatus/actions.ts
  • ExpectedExpenseManagement/actions.ts
  • CardTransactionInquiry/actions.ts
  • DailyReport/actions.ts
  • BadDebtCollection/actions.ts
  • BankTransactionInquiry/actions.ts

3. HR 도메인 진행중 (1/6)

  • EmployeeManagement/actions.ts (이미 마이그레이션되어 있었음)
  • [~] VacationManagement/actions.ts (import만 변경됨, 함수 마이그레이션 필요)

다음 세션 TODO

HR 도메인 나머지 (5개)

  • VacationManagement/actions.ts - 함수 마이그레이션 완료 필요
  • SalaryManagement/actions.ts
  • CardManagement/actions.ts
  • DepartmentManagement/actions.ts
  • AttendanceManagement/actions.ts

기타 도메인 (Approval, Production, Settings, 기타)

  • Approval: 4개
  • Production: 4개
  • Settings: 11개
  • 기타: 12개
  • 상세 목록은 체크리스트 문서 참고

빌드 검증

  • npm run build 실행하여 마이그레이션 검증

참고 사항

마이그레이션 패턴 (참고용)

// Before
import { cookies } from 'next/headers';
async function getApiHeaders() { ... }
const response = await fetch(url, { headers });

// After
import { serverFetch } from '@/lib/api/fetch-wrapper';
const { response, error } = await serverFetch(url, { method: 'GET' });
if (error) return { success: false, error: error.message };

주요 변경 포인트

  1. getApiHeaders() 함수 제거
  2. import { cookies } from 'next/headers' 제거
  3. fetch()serverFetch() 변경
  4. { response, error } 구조분해 사용
  5. 파일 다운로드(Excel/PDF)는 cookies import 유지 (custom Accept 헤더 필요)

특이사항

  • EmployeeManagement/actions.ts는 이미 serverFetch 사용 중이었음
  • uploadProfileImage 함수는 FormData 업로드라 cookies import 유지

체크리스트 문서

claudedocs/api/[IMPL-2025-12-30] fetch-wrapper-migration.md

진행률

  • 전체: 49개 파일
  • 완료: 13개 (27%)
  • 남음: 36개