feat(xo-server/config): expose cookie options (#3861)

Fixes #3850
This commit is contained in:
Julien Fontanet 2019-01-14 14:31:39 +01:00 committed by GitHub
parent a97c5f4cd9
commit 308d53dc6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -50,6 +50,13 @@
# configuration.
# redirectToHttps = true
# Settings applied to cookies created by xo-server's embedded HTTP server.
#
# See https://www.npmjs.com/package/cookie#options-1
[http.cookies]
#sameSite = true
#secure = true
# Basic HTTP.
[[http.listen]]
# Address on which the server is listening on.

View File

@ -79,14 +79,14 @@ async function loadConfiguration() {
// ===================================================================
function createExpressApp() {
function createExpressApp(config) {
const app = createExpress()
app.use(helmet())
// Registers the cookie-parser and express-session middlewares,
// necessary for connect-flash.
app.use(cookieParser())
app.use(cookieParser(null, config.http.cookies))
app.use(
expressSession({
resave: false,
@ -601,7 +601,7 @@ export default async function main(args) {
await xo.clean()
// Express is used to manage non WebSocket connections.
const express = createExpressApp()
const express = createExpressApp(config)
if (config.http.redirectToHttps) {
let port