-
Notifications
You must be signed in to change notification settings - Fork 8
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
session refresh middleware 추가 #3564
base: v13
Are you sure you want to change the base?
Conversation
release-canary |
v13.42.2-pr-3564.4 has been published! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v13 #3564 +/- ##
==========================================
+ Coverage 10.10% 10.15% +0.05%
==========================================
Files 727 732 +5
Lines 28236 28419 +183
Branches 7721 7765 +44
==========================================
+ Hits 2852 2886 +34
- Misses 25364 25513 +149
Partials 20 20 ☔ View full report in Codecov by Sentry. |
release-canary |
v13.42.2-pr-3564.5 has been published! |
release-canary |
v13.42.2-pr-3564.6 has been published! |
release-canary |
v13.42.2-pr-3564.8 has been published! |
release-canary |
v13.42.2-pr-3564.9 has been published! |
newCookies.set(name, cookie) | ||
}) | ||
|
||
const finalCookie = [...newCookies.values()].join('; ') |
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.
Map의 key는 사용하지 않아도 괜찮나요?
PR 설명
트리플에서는 각 페이지에서 어떠한 함수를 사용하느냐에 따라 세션 갱신을 진행하기도, 하지 않기도 합니다. 따라서 트리플 서비스를 계속 사용하고 있었다고 하더라도 어떤 페이지에 접속하느냐에 따라 세션 갱신이 제각각으로 진행됩니다. 이를 통일해 모든 페이지에서 세션 갱신 로직을 실행할 수 있도록 미들웨어에 세션 갱신 로직을 추가합니다.
v14의 middlware를 참고했고 단지 세션 갱신의 역할만 할 뿐 페이지 접속을 막는 것이 아니기 때문에 response의 status는 수정하지 않는 쪽으로 진행했습니다.
middleware
기본적으로 세션을 갱신하는 로직을 실행하는 미들웨어를 제공합니다.
middleware.ts
파일 예시직접
CustomMiddleware
를 작성하여 미들웨어 구성이 가능합니다.middleware.ts
파일에서next/server
로부터 타입을 import하기 때문에next.config.js
에config.resolve.fallback = { fs: false }
를 추가해야 오류가 발생하지 않습니다.