-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: 기존 authGuard 수정 및 리다이렉트 모달 추가, 프록시 경로 추가 #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📦 번들 분석 결과📊 번들 크기 요약
🔍 주요 청크 파일 (크기순)🤖 자동 생성된 번들 분석 리포트 |
⚡ Lighthouse 성능 분석 결과📊 전체 평균 점수
📈 측정 현황
📄 페이지별 상세 분석🏠 커뮤니티 페이지:
|
| 지표 | 점수 |
|---|---|
| 🚀 Performance | 70점 |
| ♿ Accessibility | 78점 |
| ✅ Best Practices | 100점 |
| 🔍 SEO | 100점 |
📊 상세 분석 보기
👥 창업자 페이지: /main/founder
| 지표 | 점수 |
|---|---|
| 🚀 Performance | 75점 |
| ♿ Accessibility | 87점 |
| ✅ Best Practices | 100점 |
| 🔍 SEO | 100점 |
📊 상세 분석 보기
🏡 홈 페이지: /main/home
| 지표 | 점수 |
|---|---|
| 🚀 Performance | 75점 |
| ♿ Accessibility | 91점 |
| ✅ Best Practices | 100점 |
| 🔍 SEO | 100점 |
📊 상세 분석 보기
🗺️ 지도 페이지: /main/maps
| 지표 | 점수 |
|---|---|
| 🚀 Performance | 75점 |
| ♿ Accessibility | 87점 |
| ✅ Best Practices | 100점 |
| 🔍 SEO | 100점 |
📊 상세 분석 보기
👤 프로필 페이지: /main/profile
| 지표 | 점수 |
|---|---|
| 🚀 Performance | 75점 |
| ♿ Accessibility | 88점 |
| ✅ Best Practices | 100점 |
| 🔍 SEO | 100점 |
📊 상세 분석 보기
🔗 전체 상세 분석 결과
📄 측정된 페이지
- /main/community
- /main/founder
- /main/home
- /main/maps
- /main/profile
모든 페이지에서 성능 측정이 완료되었습니다.
🤖 자동 생성된 Lighthouse 성능 리포트
DreamPaste
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요!!
| // 자유 게시판 | ||
| { | ||
| source: '/api/community/freeboard/:path*', | ||
| destination: `${apiBaseUrl}/community/freeboard/:path*`, | ||
| }, | ||
| // 투표 게시판 | ||
| { | ||
| source: '/api/community/votesboard/:path*', | ||
| destination: `${apiBaseUrl}/community/votesboard/:path*`, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{
source: '/api/community/:path*',
destination: `${apiBaseUrl}/community/:path*`,
},위처럼 한번에 해도 좋을거같아요!
| /** | ||
| * 고차함수(HOF) 패턴 | ||
| * | ||
| * - 인자: fn: 실제로 실행하고 싶은 액션(함수) | ||
| * - 반환: 로그인 체크가 래핑된 새 함수 | ||
| **/ | ||
| const requireAuth = | ||
| // Args: 원래 함수가 받을 인자 타입들 | ||
| <Args extends unknown[]>( | ||
| fn: (...args: Args) => void | Promise<void>, | ||
| ) => | ||
| async (...args: Args) => { | ||
| if (!(await ensureAuthed())) return; | ||
| return fn(...args); | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOF 패턴이네요 고생하셨어요
📌 개요
useAuthGuard를 고차함수(HOF) 기반requireAuth패턴으로 리팩터링하고 사용처 정리/api리라이트를 건너뛰도록 분기 추가🗒 상세 설명
1. 로그인 리다이렉트 오버레이 추가 (
LoginRedirectOverlay)비로그인 상태에서 좋아요/댓글 작성 등 보호된 액션을 호출할 때 띄우는 로그인 안내 모달 오버레이를 추가했습니다.
핵심 기술 및 구현사항
useOverlay기반 오버레이로 구성하여, 어디서든 동일한 UX의 로그인 안내 모달을 호출 가능pathname)을returnTo쿼리로 함께 전달해, 로그인 후 원래 페이지로 복귀할 수 있도록 지원pointer-events를 사용해, 오버레이 전체는 클릭 차단, 모달 내부만 인터랙션 가능하도록 레이아웃 처리사용 예시
2.
useAuthGuard리팩터링 (HOF 패턴 도입 + 사용처 정리)guard(fn)/ensureAuthed()형태로 흩어져 있던 인증 가드 패턴을,고차함수(HOF) 기반의
requireAuth하나로 모아 재사용성을 높였습니다.핵심 기술 및 구현사항
useAuthGuard반환값 정리authed: 현재 로그인 여부requireAuth(fn): 로그인 확인이 래핑된 액션 함수를 반환비인증 상태일 때는:
LoginRedirectOverlay오버레이를 띄우고기존
guard(...)호출부를requireAuth(...)형태로 정리CommentInput,LikeButtonComment,LikeButtonPost등에서 중복 가드 호출 제거requireAuth(handleToggleLike)등으로 연결사용 예시
3. 프록시 경로 확장 및 SSR 분기 추가 (
next.config.js,api-client.ts)쿠키 기반 인증이 필요한 게시판 API에 대해 프록시를 확장하고,
SSR 환경에서 발생하던
Invalid URL문제를 방지하기 위한 분기를 추가했습니다.핵심 기술 및 구현사항
next.config.js/api/community/freeboard/:path*→${apiBaseUrl}/community/freeboard/:path*/api/community/votesboard/:path*→${apiBaseUrl}/community/votesboard/:path*api-client.tsCOOKIE_REQUIRED_PATHS에 자유/투표 게시판 경로 추가/api프록시를 타도록 처리isBrowser분기 추가typeof window === 'undefined'(SSR/RSC)인 경우,baseURL과url을 변경하지 않고 그대로 사용 →Node 환경에서
new URL()호출 시Invalid URL가 발생하지 않도록 방지📸 스크린샷
UI 변경이 있을 경우, Before / After 스크린샷을 첨부해주세요.
AS-IS
TO-BE
🔗 이슈
머지 시 자동으로 닫힐 이슈 번호를
closes #32처럼closes #<번호>로 적어주세요.closes #90
✅ 체크리스트
🧪 테스트 방법
변경 사항을 검증한 방법을 간단히 적어주세요!
비로그인 상태에서:
로그인 상태에서:
자유/투표 게시판 상세 페이지 SSR 진입 시 에러 로그(
Invalid URL)가 발생하지 않는지 확인📝 추가 노트
“조회는 공개, 뮤테이션만 프록시/쿠키 필요” 기준으로 경로를 더 세분화해야 할지 검토 부탁드립니다.
( 뮤테이션만 프록시 대상이 돼야하는지)
Invalid URL에러로 인하여 isBrowser 분기를 추가하였는데 이 방식이 맞는 건지 검토 부탁드립니다.후속 작업