Skip to content

Commit

Permalink
update middleware to update token and change regex
Browse files Browse the repository at this point in the history
  • Loading branch information
xtian7489 committed Sep 5, 2024
1 parent 795a582 commit 29cd40c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/lib/utils/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function updateSession(request) {

if (!token) return
const res = NextResponse.next()
if (expTime < currentTime) {
// if (expTime < currentTime) {
const newToken = await refreshToken()
const expires = new Date(Date.now() + oneDay * 2)
res.cookies.set({
Expand All @@ -65,7 +65,7 @@ export async function updateSession(request) {
secure: process.env.NODE_ENV === 'production',
expires
})
}
// }
return res
}
} catch (err) {
Expand Down
12 changes: 2 additions & 10 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,11 @@ export async function middleware(request) {
} catch (error) {
return await rejectUser(request)
}
return await updateSession(request)
}
return await updateSession(request)
}


export const config = {
matcher: [/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
matcher: "/((?!api|static|.*\\..*|_next).*)",
};

0 comments on commit 29cd40c

Please sign in to comment.