Skip to content

Commit

Permalink
Use __Secure cookie prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Dec 21, 2023
1 parent 049bd75 commit 1eb6665
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const multiAuthMiddleware = (request) => {
const cookiePointerName = 'multi_auth.user-id'
const hasCookiePointer = request.cookies?.has(cookiePointerName)
// is there a session?
const sessionCookieName = 'next-auth.session-token'
const sessionCookieName = '__Secure-next-auth.session-token'
const hasSession = request.cookies?.has(sessionCookieName)

if (!hasCookiePointer || !hasSession) {
Expand Down
2 changes: 1 addition & 1 deletion pages/api/auth/[...nextauth].js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const getAuthOptions = (req, res) => ({
},
cookies: {
sessionToken: {
name: 'next-auth.session-token',
name: '__Secure-next-auth.session-token',
options: {
httpOnly: true,
sameSite: 'lax',
Expand Down
2 changes: 1 addition & 1 deletion pages/api/signout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default (req, res) => {
const cookiePointerName = 'multi_auth.user-id'
const userId = req.cookies[cookiePointerName]
// is there a session?
const sessionCookieName = 'next-auth.session-token'
const sessionCookieName = '__Secure-next-auth.session-token'
const sessionJWT = req.cookies[sessionCookieName]

if (!userId || !sessionJWT) {
Expand Down

0 comments on commit 1eb6665

Please sign in to comment.