Skip to content

[FLIZ-462] feat: axios 토큰 검사 시, SSR에서의 window 참조 방지를 위한 조건 설정 - #302

Merged
MaSeungHyun merged 1 commit into
devfrom
FLIZ-462/feat/root
Aug 8, 2025
Merged

[FLIZ-462] feat: axios 토큰 검사 시, SSR에서의 window 참조 방지를 위한 조건 설정#302
MaSeungHyun merged 1 commit into
devfrom
FLIZ-462/feat/root

Conversation

@MaSeungHyun

@MaSeungHyun MaSeungHyun commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

📝 작업 내용

기존 SSR에서도 토큰이 없는 경우 window를 사용할 수 있는 경우를 방지하기 위하여 조건값을 추가하였습니다.

❓ 왜 기존 코드에서 조건만 더했는가
StackOveflow 및 블로그를 확인해본 결과
axios 사용처 혹은 middleware에서 토큰을 검사 후 NextResponse.redirect()를 통하여 페이지를 이동시켜주는 것을 확인하였습니다.

좀 더 안전하게 진입을 막기 위해서 클라이언트 컴포넌트에서 (로그아웃 후 뒤로가기를 하였을 때 마이페이지에 진입할 수 밖에 없는 상황이라 MyPage에서 토큰을 검사하려하였으나 Next useRouter 이벤트 사용)
클라이언트 컴포넌트에서 검사하고자한다면, access-token만을 검사할 수 있는데, access-token이 없는 상태라고 login 페이지로 사용자를 보내주는 것은 동작에 맞지 않는다고 생각하였습니다.(리프레시가 있으면 access-token이 만료됐거나 없을 때 재발급할 수 있기 때문에)

Next 서버에서 검사하면 보일러 플레이트가 발생할 것 같으며, 뒤로가기 후, core 파일의 axios가 실행되는 것을 확인하고 core.ts 단에서 방지하고자 하였습니다.

📷 스크린샷 (선택)

💬 리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요
ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@MaSeungHyun MaSeungHyun self-assigned this Aug 7, 2025
@MaSeungHyun MaSeungHyun added the ✨feat 새로운 기능 추가 label Aug 7, 2025
@MaSeungHyun
MaSeungHyun requested review from choi-ik and yjc2021 August 8, 2025 00:24
@MaSeungHyun
MaSeungHyun merged commit f36d24a into dev Aug 8, 2025
1 check passed
@MaSeungHyun
MaSeungHyun deleted the FLIZ-462/feat/root branch August 8, 2025 05:20
choi-ik added a commit to choi-ik/FitLink-FE that referenced this pull request Aug 8, 2025
…nks#302)

FLIZ-462 feat: axios 토큰 검사 시,  SSR에서의 window 참조 방지를 위한 조건 설정
MaSeungHyun added a commit to MaSeungHyun/FitLink-FE that referenced this pull request Aug 8, 2025
…nks#302)

FLIZ-462 feat: axios 토큰 검사 시,  SSR에서의 window 참조 방지를 위한 조건 설정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant