Created
October 22, 2022 21:26
-
-
Save itwasmattgregg/aad358ec48b29bac9e3e46890943e8bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withIronSessionApiRoute, withIronSessionSsr } from 'iron-session/next'; | |
const sessionOptions = { | |
password: process.env.SECRET_COOKIE_PASSWORD, | |
cookieName: 'next-iron-session/examples/next.js', | |
// secure: true should be used in production (HTTPS) but can't be used in development (HTTP) | |
cookieOptions: { | |
secure: process.env.NODE_ENV === 'production', | |
}, | |
}; | |
export function withSessionRoute(handler) { | |
return withIronSessionApiRoute(handler, sessionOptions); | |
} | |
export function withSessionSsr(handler) { | |
return withIronSessionSsr(handler, sessionOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment