Skip to content

Commit

Permalink
Bump next-session and set cookie expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangvvo committed Sep 20, 2021
1 parent 230b2a9 commit 81513af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion api-lib/middlewares/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@ export default function session(req, res, next) {
client: req.dbClient,
stringify: false,
});
return nextSession({ store: mongoStore })(req, res, next);
return nextSession({
store: mongoStore,
cookie: {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
maxAge: 2 * 7 * 24 * 60 * 60, // 2 weeks,
path: '/',
sameSite: 'strict',
},
touchAfter: 1 * 7 * 24 * 60 * 60 * 1000, // 1 week
})(req, res, next);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"nanoid": "^3.1.25",
"next": "^11.1.2",
"next-connect": "^0.10.2",
"next-session": "^3.4.1",
"next-session": "^3.4.3",
"nodemailer": "^6.6.3",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
Expand Down

1 comment on commit 81513af

@vercel
Copy link

@vercel vercel bot commented on 81513af Sep 20, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.