aboutsummaryrefslogtreecommitdiffstats
path: root/hocs/withSession.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-02 22:28:11 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-02 23:54:56 +0200
commitf08f6ca0a9d337efff280d4d1669a41b5d9c31c2 (patch)
tree7dee778ba742deb5f499f2aa08a1ba040606d633 /hocs/withSession.js
parent9f74c550927671f4ded301d0cf3e9d592716375c (diff)
downloadmy_apps-f08f6ca0a9d337efff280d4d1669a41b5d9c31c2.tar.gz
my_apps-f08f6ca0a9d337efff280d4d1669a41b5d9c31c2.tar.bz2
my_apps-f08f6ca0a9d337efff280d4d1669a41b5d9c31c2.zip
finish translations, force maximize
Diffstat (limited to 'hocs/withSession.js')
-rw-r--r--hocs/withSession.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/hocs/withSession.js b/hocs/withSession.js
new file mode 100644
index 0000000..0361db3
--- /dev/null
+++ b/hocs/withSession.js
@@ -0,0 +1,14 @@
+// this file is a wrapper with defaults to be used in both API routes and `getServerSideProps` functions
+import {withIronSession} from 'next-iron-session'
+
+export default function withSession(handler) {
+ return withIronSession(handler, {
+ password: process.env.MYAPPS_SECRET_COOKIE_PASSWORD,
+ cookieName: 'myapps_session',
+ cookieOptions: {
+ // the next line allows to use the session in non-https environments like
+ // Next.js dev mode (http://localhost:3000)
+ secure: process.env.NODE_ENV === 'production' ? true : false,
+ },
+ })
+}