Skip to content

fix: 라우팅 경로 수정#111

Merged
heeeeyong merged 8 commits intodevelopfrom
feat/api-auth
Aug 13, 2025
Merged

fix: 라우팅 경로 수정#111
heeeeyong merged 8 commits intodevelopfrom
feat/api-auth

Conversation

@heeeeyong
Copy link
Collaborator

@heeeeyong heeeeyong commented Aug 13, 2025

#️⃣연관된 이슈

ex) #이슈번호, #이슈번호

📝작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

Summary by CodeRabbit

  • Refactor

    • 회원가입 라우팅을 중첩 구조에서 평면 구조로 재구성했습니다.
    • 회원가입 단계에 직접 접근 가능한 경로: /signup 및 /signup/genre.
    • 네비게이션 일관성(뒤로가기, 링크 공유) 개선 및 다른 페이지 영향 없음.
  • Chores

    • 회원가입 요청/내비게이션에서 사용자 닉네임 키명이 일관되게 변경되어(별칭 유지) 이후 단계로 전달됩니다.

@vercel
Copy link

vercel bot commented Aug 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
thip Ready Preview Comment Aug 13, 2025 5:25pm

@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

라우터의 중첩된 Signup 경로를 평면화하고, API 요청형식에서 nickNamenickname으로 필드명 변경 및 해당 호출부(SignupGenre)와 라우팅 상태 전파를 이에 맞게 수정했습니다.

Changes

Cohort / File(s) Summary
Routing updates
src/pages/index.tsx
중첩된 signup 라우트를 제거하고 signupSignupNickname, signup/genreSignupGenre로 평면 라우트로 재정의. Signup 컴포넌트 임포트는 주석 처리됨.
API 타입 변경
src/api/users/postSignup.ts
요청 타입의 필드명 nickName: stringnickname: string으로 변경. 함수 시그니처(이름)는 유지되나 요청 페이로드 스키마가 변경됨.
Signup flow update
src/pages/signup/SignupGenre.tsx
postSignup 호출과 '/signupdone'로 내비게이션 시 전달하는 상태에서 nickNamenickname으로 키 변경. 동작 흐름(성공 시 이동)은 동일.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Router
  participant SignupNickname
  participant SignupGenre

  User->>Router: GET /signup
  Router-->>SignupNickname: render SignupNickname

  User->>Router: GET /signup/genre
  Router-->>SignupGenre: render SignupGenre
Loading
sequenceDiagram
  participant SignupGenre
  participant API as postSignup
  participant Router

  SignupGenre->>API: POST /users/signup { aliasName, nickname }
  API-->>SignupGenre: { success: true }
  SignupGenre->>Router: navigate('/signupdone', { aliasName, nickname })
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • ho0010

Poem

토끼가 깡총, 코드 위를 뛰며 말하네 🐇
경로는 펴고, 필드는 다듬었지요.
nickName은 이제 사라지고, nickname으로 춤춰요.
라우터는 짝짝, 컴포넌트는 찰칵—
당근 한 조각에 배포 축하! 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/api-auth

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/index.tsx (1)

8-8: 주석 처리된 import는 제거하세요

버전 관리가 있으므로 주석으로 남겨둘 필요가 없습니다. 불필요한 주석 코드는 혼동을 유발합니다.

아래 변경으로 정리 가능합니다.

-// import Signup from './signup/Signup';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6b278 and 0cda714.

📒 Files selected for processing (1)
  • src/pages/index.tsx (2 hunks)

Comment on lines +47 to +48
<Route path="signup" element={<SignupNickname />} />
<Route path="signup/genre" element={<SignupGenre />} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

중첩 → 평면 라우트 전환은 타당하지만, 부모(Signup) 레이아웃/가드 소실 여부를 확인해주세요

이전 구조에서 Signup 컴포넌트가 공통 레이아웃(스텝 진행바, 공통 헤더 등)이나 Outlet/컨텍스트/가드 역할을 했다면, 평면 라우트로 전환되면서 해당 역할이 사라졌을 수 있습니다. 특히 /signup/genre에 직접 접근을 차단하는 가드가 빠지면 플로우가 깨질 수 있습니다.

  • 확인 포인트
    • Signup.tsx가 <Outlet /> 또는 useOutletContext로 하위 스텝에 상태/가드를 제공했는지
    • SignupNickname/SignupGenre가 부모 컨텍스트나 레이아웃에 의존하지 않는지
    • navigate("genre")/to="genre" 등 상대 네비게이션이 여전히 기대대로 동작하는지

필요 시, signup/genre 라우트에 최소한의 가드를 씌워 플로우 보장을 권장합니다.

적용 예시(가드 컴포넌트가 있다는 전제):

-        <Route path="signup" element={<SignupNickname />} />
-        <Route path="signup/genre" element={<SignupGenre />} />
+        <Route path="signup" element={<SignupNickname />} />
+        <Route
+          path="signup/genre"
+          element={
+            <SignupGuard>
+              <SignupGenre />
+            </SignupGuard>
+          }
+        />

가드 예시 구현(외부 파일; 실제 앱 상태소스에 맞게 수정 필요):

import { Navigate, useLocation } from 'react-router-dom';

// TODO: 실제 구현으로 교체(예: Redux/Zustand/Recoil/Query 등에서 닉네임 완료 여부 읽기)
function useCanProceedToGenre() {
  return false;
}

export function SignupGuard({ children }: { children: React.ReactNode }) {
  const canProceed = useCanProceedToGenre();
  const location = useLocation();
  if (!canProceed) {
    return <Navigate to="/signup" replace state={{ from: location }} />;
  }
  return <>{children}</>;
}

아래 스크립트로 잠재 리스크를 빠르게 점검할 수 있습니다.


🏁 Script executed:

#!/bin/bash
# 1) Signup 래퍼 파일 존재 여부 확인
fd -a --glob 'src/**/signup/Signup.*'

# 2) Outlet/OutletContext 의존성 확인(부모 컨텍스트 의존 여부)
rg -n -A2 -B2 $'useOutletContext|<Outlet' src

# 3) 상대 네비게이션(genre) 사용처 확인
rg -n -A1 -B1 $'navigate\\([\'"]genre[\'"]\\)|to=[\'"]genre[\'"]' src

Length of output: 361


Signup.tsx의 미사용 레이아웃 확인 및 중첩 구조 적용 여부 결정

현재 검증 결과:

  • src/pages/signup/Signup.tsx<Outlet />이 존재하지만, src/pages/index.tsx의 라우트가 모두 평면 구조로 정의되어 있어 해당 레이아웃이 렌더링되지 않습니다.
  • SignupNicknameSignupGenre 양쪽 컴포넌트에서 useOutletContext나 부모 상태·컨텍스트 의존 코드는 발견되지 않았습니다.
  • navigate('genre') 또는 to="genre" 같은 상대 경로 네비게이션도 사용되지 않고 있습니다.

해결 방향 제안:

  • 부모 레이아웃/가드를 더 이상 사용하지 않을 계획이라면, Signup.tsx와 관련 파일을 제거하거나 단일 페이지 방식으로 리팩터링하세요.
  • 여전히 단계별 레이아웃(스텝 진행바·헤더)이나 가드 로직이 필요하다면, 아래처럼 중첩 라우트 구조로 돌아가길 권장합니다.
<Routes>
-  <Route path="signup" element={<SignupNickname />} />
-  <Route path="signup/genre" element={<SignupGenre />} />
+  <Route path="signup" element={<Signup />}>
+    <Route index element={<SignupNickname />} />
+    <Route
+      path="genre"
+      element={
+        <SignupGuard>
+          <SignupGenre />
+        </SignupGuard>
+      }
+    />
+  </Route>
</Routes>

필요하다면, 다음과 같은 가드 컴포넌트를 참고해 실제 앱 상태 관리 로직에 맞춰 구현하세요:

import { Navigate, useLocation } from 'react-router-dom';

function useCanProceedToGenre() {
  // TODO: 닉네임 완료 여부 등을 실제 상태에서 읽어오기
  return false;
}

export function SignupGuard({ children }: { children: React.ReactNode }) {
  const canProceed = useCanProceedToGenre();
  const location = useLocation();
  return canProceed
    ? <>{children}</>
    : <Navigate to="/signup" replace state={{ from: location }} />;
}
🤖 Prompt for AI Agents
In src/pages/index.tsx around lines 47-48, the Signup parent layout
(src/pages/signup/Signup.tsx) contains an Outlet but your routes are defined
flat so that layout never renders; either remove/refactor the unused Signup
layout and related files if you don't need a multi-step layout, or convert the
routes to nested routes so the parent layout wraps the child steps: replace the
two flat signup routes with a parent Route path="signup" element={<Signup /> }
and put nested Route path="" element={<SignupNickname />} and Route path="genre"
element={<SignupGenre />} (optionally wrap child routes with a guard component
if you need step protection), and update any imports and navigation to use
absolute or relative paths consistent with nesting.

@heeeeyong heeeeyong self-assigned this Aug 13, 2025
@heeeeyong heeeeyong added the 🐞 BugFix Something isn't working label Aug 13, 2025
@heeeeyong heeeeyong merged commit 40fedfa into develop Aug 13, 2025
2 of 3 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (2)
src/pages/signup/SignupGenre.tsx (2)

34-41: 안전 폴백 추가: 히스토리 미보유 시 /signup으로 이동

히스토리가 없으면 navigate(-1)이 동작하지 않을 수 있으므로, window.history.length를 확인해 뒤로 갈 수 없을 땐 회원가입 첫 단계(/signup)로 폴백하도록 수정하세요.

수정 대상:

  • 파일: src/pages/signup/SignupGenre.tsx
  • 위치: 34~41행

제안하는 코드 변경 예시:

-    // nickname이 없으면 이전 페이지로 돌아가기
-    if (!nickname) {
-      console.log('❌ nickname이 전달되지 않았습니다.');
-      console.log('❌ 이전 페이지로 돌아갑니다.');
-      navigate(-1);
-      return;
-    }
+    // nickname이 없으면 이전 페이지로 돌아가기 (폴백 포함)
+    if (!nickname) {
+      console.error('❌ nickname이 전달되지 않았습니다.');
+      if (window.history.length > 1) {
+        navigate(-1);
+      } else {
+        // 회원가입 첫 단계 경로로 폴백
+        navigate('/signup', { replace: true });
+      }
+      return;
+    }

1-125: SignupDone.tsx의 상태 키 불일치(nickname vs nickName) 수정 필요

SignupGenre에서 navigate('/signupdone', { state: { nickname } })로 전달한 키(nickname)와 SignupDone에서 받고 있는 키(nickName)가 달라 닉네임이 제대로 표시되지 않습니다. 아래 파일을 수정해주세요.

  • 수정 대상: src/pages/signup/SignupDone.tsx
    • location.state에서 nickNamenickname으로 변경
    • 코드 내 모든 nickName 사용 부분을 nickname으로 통일
- const { nickName, aliasName } = location.state || {};
+ const { nickname, aliasName } = location.state || {};

- if (!nickName || !aliasName) {
+ if (!nickname || !aliasName) {

- <div className="title">안녕하세요, {nickName}님</div>
+ <div className="title">안녕하세요, {nickname}님</div>

- <div className="username">{nickName}</div>
+ <div className="username">{nickname}</div>
  • /genres.json 파일은 public/genres.json 경로에 존재하므로 fetch 경로(/genres.json)에는 문제가 없습니다.
  • 나머지 라우팅·상태 전파 로직은 정상 동작합니다.
🧹 Nitpick comments (6)
src/pages/signup/SignupGenre.tsx (6)

25-27: location.state 타입 명시로 안정성 향상

location.state가 any로 추론되어 오타/스키마 변경에 취약합니다. state 타입을 명시해 런타임 이슈를 줄이는 것을 권장합니다.

다음 변경을 제안합니다:

 import { useNavigate, useLocation } from 'react-router-dom';
+import type { Location } from 'react-router-dom';
@@
-  const location = useLocation();
+  const location = useLocation() as Location & { state?: { nickname?: string } };
@@
-  const nickname = location.state?.nickname;
+  const nickname = location.state?.nickname;

Also applies to: 23-23, 2-2


67-70: 객체 리터럴 단축 속성 사용으로 가독성 개선

nickname: nicknamenickname으로 단축 가능합니다.

       const result = await postSignup({
         aliasName: selectedAlias.subTitle,
-        nickname: nickname,
+        nickname,
       });

75-78: 네비게이션 state도 단축 속성 사용

동일하게 단축 표기를 적용하면 일관성이 좋아집니다.

         navigate('/signupdone', {
           state: {
             aliasName: selectedAlias.subTitle,
-            nickname: nickname,
+            nickname,
           },
         });

18-22: 중복 제출 방지 및 UX 개선: 로딩 상태 도입

빠른 연속 클릭 시 다중 요청 가능성이 있습니다. 로딩 상태를 추가해 방지하는 것을 권장합니다.

@@
   >([]);
   const [selectedAlias, setSelectedAlias] = useState<{
     id: string;
     subTitle: string;
   } | null>(null);
+  const [isSubmitting, setIsSubmitting] = useState(false);
@@
-  const handleNextClick = async () => {
+  const handleNextClick = async () => {
-    if (!selectedAlias || !nickname) return;
+    if (!selectedAlias || !nickname || isSubmitting) return;
 
     console.log('=== 🚀 다음 버튼 클릭 ===');
     console.log('🎭 선택된 alias:', selectedAlias);
     console.log('👤 nickname:', nickname);
 
     try {
+      setIsSubmitting(true);
       console.log('🚀 postSignup API 호출 시작...');
       // ✅ 쿠키는 브라우저가 자동으로 전송
       const result = await postSignup({
         aliasName: selectedAlias.subTitle,
         nickname,
       });
@@
     } catch (error) {
       console.error('💥 회원가입 중 오류 발생:', error);
+    } finally {
+      setIsSubmitting(false);
     }
   };
@@
-        isNextActive={!!selectedAlias}
+        isNextActive={!!selectedAlias && !isSubmitting}

Also applies to: 57-86, 96-97


46-51: fetch 취소 처리로 언마운트/전환 시 경합 및 메모리 누수 방지

AbortController를 사용해 언마운트 시 fetch를 중단하는 것을 권장합니다.

-  useEffect(() => {
-    fetch('/genres.json')
-      .then(res => res.json())
-      .then(data => setGenres(data))
-      .catch(console.error);
-  }, []);
+  useEffect(() => {
+    const ac = new AbortController();
+    (async () => {
+      try {
+        const res = await fetch('/genres.json', { signal: ac.signal });
+        const data = await res.json();
+        setGenres(data);
+      } catch (e) {
+        if ((e as any)?.name !== 'AbortError') console.error(e);
+      }
+    })();
+    return () => ac.abort();
+  }, []);

29-44: 디버그 콘솔 로그 정리 권장

현재 닉네임 등 민감 정보가 콘솔에 남습니다. 배포 시에는 제거하거나 개발 모드에서만 출력하도록 하세요.

예시:

const debug = import.meta.env.MODE !== 'production';
if (debug) {
  console.log('👤 nickname:', nickname);
}

Also applies to: 60-66

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cda714 and 4e8068c.

📒 Files selected for processing (2)
  • src/api/users/postSignup.ts (1 hunks)
  • src/pages/signup/SignupGenre.tsx (1 hunks)
🔇 Additional comments (1)
src/api/users/postSignup.ts (1)

17-20: 전역 axios 인스턴스에 withCredentials 설정 확인됨

src/api/index.ts(13)에서 withCredentials: true가 이미 설정되어 있어 postSignup 함수에는 별도 인증/쿠키 전송 설정이 필요 없습니다.

Comment on lines 3 to 6
export interface PostSignupRequest {
aliasName: string;
nickName: string;
nickname: string;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

요청 필드명 nickNamenickname 변경 반영 👍

타입 정의가 깔끔하게 정리되었습니다. 이제 호출부 전역에서 남아있는 nickName 사용이 없는지만 확인하면 됩니다.

레거시 키워드 잔존 여부를 점검하는 스크립트입니다.


🏁 Script executed:

#!/bin/bash
# 레거시 필드명 'nickName' 사용 흔적 점검
rg -n --hidden --glob '!*dist/*' --glob '!*build/*' --glob '!*node_modules/*' '\bnickName\b' || true

Length of output: 430


레거시 필드명 nickName 사용 잔존 – 추가 변경 필요
다음 파일에서 여전히 nickName이 사용되고 있으니, 전부 nickname으로 변경해주세요:

  • src/pages/signup/SignupDone.tsx:12
  • src/pages/signup/SignupDone.tsx:23
  • src/pages/signup/SignupDone.tsx:34
  • src/pages/signup/SignupDone.tsx:41
🤖 Prompt for AI Agents
In src/api/users/postSignup.ts around lines 3 to 6 the interface still uses the
legacy field naming; change any remaining occurrences of "nickName" to
"nickname". Update this file's PostSignupRequest to use nickname and then update
the referenced UI files (src/pages/signup/SignupDone.tsx lines 12, 23, 34, 41)
to read/write the same "nickname" property so names are consistent across API
and frontend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant