Skip to content

Commit 98fefb4

Browse files
Added the cookie domain option in the config
Changes: modified: .env.example modified: web/web.js
1 parent 5ee7435 commit 98fefb4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ SMTP_PASSWORD=
1111
NOTIFICATION_EMAIL=
1212
NOTIFICATION_FROM=
1313

14+
COOKIE_DOMAIN=localhost
15+
1416
ALLOW_NOTIFICATIONS=true
1517
SUCCESS_NOTIFICATIONS=false
1618
ERROR_NOTIFICATIONS=false

web/web.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ web.use(cookieParser())
1919
web.use(cors({ origin: true, credentials: true }))
2020
web.use(bodyParser.urlencoded({ extended: false }))
2121

22-
/**Error handling */
23-
web.use(function (err, _req, res, next) {
24-
if (err.code === 'EBADCSRFTOKEN') {
25-
return res.status(403).json(err.message)
26-
}
27-
next(err)
28-
})
2922
/** */
3023
const nextYear = new Date().getFullYear() + 1
3124
const exp = new Date().setFullYear(nextYear)
@@ -34,13 +27,22 @@ web.use(cookieSession({ name: 'deployer_session', keys: ['mysupersecret'], expir
3427
web.use(csrf({
3528
cookie: {
3629
sameSite: 'lax',
37-
secure: false
30+
secure: false,
31+
domain: process.env.COOKIE_DOMAIN | 'localhost'
3832
},
3933
ignoreMethods: process.env.NODE_ENV === 'development' ? ['POST', 'PUT', 'DELETE', 'GET', 'OPTIONS'] : ['GET', 'HEAD', 'OPTIONS'],
4034
sessionKey: 'de'
4135
}))
4236
web.use(express.static(path.join(__dirname, 'public')))
4337

38+
/**Error handling */
39+
web.use(function (err, _req, res, next) {
40+
if (err.code === 'EBADCSRFTOKEN') {
41+
return res.status(403).json(err.message)
42+
}
43+
next(err)
44+
})
45+
4446
web.use('/', apiRouter)
4547
web.use('/config', configRouter)
4648

0 commit comments

Comments
 (0)