Skip to content
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

feat: private routing #96

Merged
merged 3 commits into from
Sep 23, 2024
Merged

feat: private routing #96

merged 3 commits into from
Sep 23, 2024

Conversation

jun0811
Copy link
Contributor

@jun0811 jun0811 commented Sep 19, 2024

미들웨어로 구현할려고 했지만
저희의 토큰이 localStorage에 저장되어 있습니다.
이 방식으로 할때는 Cookie를 새로 만들어주거나 부가적인 작업이 더 필요해집니다

그래서 일단은 layout에서 체크해서 리다이렉트 시키는 방식으로 구현하였습니다

@kichul7493
Copy link
Contributor

구현하신 방법은 인증을 거치지 않은 사용자가 인증이 필요한 페이지에 접근하게 되면 페이지가 화면에 렌더링 된 후에 페이지 이동이 발생하는 문제가 있습니다.
localStorage에 token 정보가 있는 걸로는 사용자의 인증 여부를 확인할 수 없을 것으로 생각됩니다.
사용자 인증은 next-auth를 활용하고 있으니, next-auth의 기능을 활용해서 미들웨어에서 OAuth 로그인 여부를 확인하는 방법을 사용하는 게 어떨까 싶습니다.

Copy link
Contributor

@kichul7493 kichul7493 left a comment

Choose a reason for hiding this comment

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

잘 작성해주셨네요! 수고 하셨습니다!

@kichul7493 kichul7493 merged commit 798df6e into dev Sep 23, 2024
1 check passed
@kichul7493 kichul7493 deleted the feature/#88-private-routing branch September 23, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants