From 9bf90bc88032fa45fd232f4a7f41faef6cc0fc3e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 29 Jan 2021 20:45:54 +0100 Subject: [PATCH] - make cookie time configurable (default: 2 years) - make cookie https setting configurable (default true in production) - ensure cookie is set to `path: /` to fix redirect problem --- webapp/config/index.js | 3 +++ webapp/nuxt.config.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webapp/config/index.js b/webapp/config/index.js index ccc30da73..8aa5b157a 100644 --- a/webapp/config/index.js +++ b/webapp/config/index.js @@ -28,6 +28,9 @@ const sentry = { const options = { VERSION: process.env.VERSION || pkg.version, DESCRIPTION: process.env.DESCRIPTION || pkg.description, + // Cookies + COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default + COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly } const CONFIG = { diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 912710ad8..d6ac6a3f0 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -191,7 +191,13 @@ export default { apollo: { tokenName: metadata.COOKIE_NAME, // optional, default: apollo-token cookieAttributes: { - expires: 1, // optional, default: 7 (days) + expires: CONFIG.COOKIE_EXPIRE_TIME, // optional, default: 7 (days) + /** * Define the path where the cookie is available. Defaults to '/' */ + // For some reason this can vary - lets see if setting this helps. + path: '/', // optional + /** * A Boolean indicating if the cookie transmission requires a + * secure protocol (https). Defaults to false. */ + secure: CONFIG.COOKIE_HTTPS_ONLY, }, // includeNodeModules: true, // optional, default: false (this includes graphql-tag for node_modules folder)