-
Notifications
You must be signed in to change notification settings - Fork 1
[FE-Fix] 리프래시 토큰 로직 수정 및 웹서버 https 설정 #404
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
WalkthroughThe updates introduce HTTPS support for the development server, refactor server middleware setup, and adjust authentication flows to ensure token refresh occurs before login checks. Error handling is enhanced with new refresh token error codes, and related logic is updated to recognize them. Minor code cleanups and route path adjustments are also included. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant Server
participant AuthUtils
User->>Browser: Navigate to main route
Browser->>AuthUtils: refresh()
AuthUtils-->>Browser: (refresh complete)
Browser->>AuthUtils: isLogin()
alt Not logged in
Browser->>User: Redirect to login page
else Logged in
Browser->>User: Render main page
end
sequenceDiagram
participant Dev
participant Server
participant HTTPS
participant HTTP
Dev->>Server: Start server (createServer)
alt Development
Server->>HTTPS: create HTTPS server with TLS cert/key
HTTPS-->>Dev: Log HTTPS URL
else Production
Server->>HTTP: app.listen (HTTP)
HTTP-->>Dev: Log HTTP URL
end
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
dioo1461
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.
잘 작동하네요! 고생하셨습니다~~
| isTooManyRequestsError = () => this.#status === 429; | ||
|
|
||
| isInvalidRefreshTokenError = () => this.#code === 'O006'; | ||
| isInvalidRefreshTokenError = () => this.#code === 'O006' || this.#code === 'RT001'; |
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.
p2;
O006 에러가 RTxxx로 변경되었으므로 해당 에러를 체크하는 부분은 빼도 될 것 같습니다!
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.
28a9158 수정했씁니다!!
#️⃣ 연관된 이슈>
📝 작업 내용> 이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)
sever/index.js코드를 고려하여, 로컬에서도 미들웨어 로직을 적용할 수 있도록 https 설정합니다(기존에는vite설정에 의존하여 불가능하였음). 이제pnpm run dev로도 https 서버를 띄울 수 있습니다.회의에서 생각했던 서버에서의 쿠키 체크 및 리프래시는 아래 두가지 이유 때문에 불가능했습니다.
path가 알고 보니/api/v1/refresh-token으로 설정되어 있어서, 나머지 요청들에는 쿠키가 안 붙어서 감. 그래서 체크가 불가능path를/와 같이 설정하여 쿠키 존재 여부에 따라서 네트워크 요청을 줄일 수는 있음 (리프래시 없으면 서버단에서 리다이렉트가 되니까), 그렇다고 해도refresh로직 자체는 서버에서 실행 불가. 액세스 토큰이 브라우저 메모리에 저장되어 있기 때문.그래서 아래와 같이 해결했습니다.
refresh토큰이 아예 존재하지 않는 경우 받는 에러코드인RT001를 추가하여, 최초 로그인과 재로그인을 구분합니다.useEffect내부의refresh를main진입점의beforeLoad로 이동하여, 토큰이 필요한 페이지들의 다른 모든 로직보다refresh를 우선적으로 진행하도록 합니다.🙏 여기는 꼭 봐주세요! > 리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요
application-dev파일Secure: false가 아닌Secure: true에서 동작합니다!!Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Style