From 5938ce11f1d11f8be26acec4c63fb6a678aaac2f Mon Sep 17 00:00:00 2001 From: Juned Kazi Date: Tue, 24 Mar 2020 07:32:13 -0700 Subject: [PATCH] fix: address chrome cookie SameSite issue --- bin/stencil-start | 1 + server/lib/utils.js | 2 +- server/plugins/renderer/renderer.module.js | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/stencil-start b/bin/stencil-start index 0a40c699..b219defb 100755 --- a/bin/stencil-start +++ b/bin/stencil-start @@ -230,6 +230,7 @@ function startServer() { }, proxy: "localhost:" + stencilServerPort, tunnel: tunnel, + https: Url.parse(staplerUrl).protocol === 'https:' }); // Handle manual reloading of browsers by typing 'rs'; diff --git a/server/lib/utils.js b/server/lib/utils.js index 9add5abf..e68e2950 100644 --- a/server/lib/utils.js +++ b/server/lib/utils.js @@ -14,7 +14,7 @@ function stripDomainFromCookies(cookies) { const fixedCookies = []; _.forEach(cookies, function(cookie) { - fixedCookies.push(cookie.replace(/(?:;\s)?domain=(?:.+?)(;|$)/, '$1')); + fixedCookies.push(cookie.replace(/(?:;\s)?domain=(?:.+?)(;|$)/, '$1').replace('; SameSite=none', '')); }); return fixedCookies; diff --git a/server/plugins/renderer/renderer.module.js b/server/plugins/renderer/renderer.module.js index 88557565..3ecebab2 100644 --- a/server/plugins/renderer/renderer.module.js +++ b/server/plugins/renderer/renderer.module.js @@ -246,6 +246,10 @@ internals.parseResponse = function (bcAppData, request, response, responseArgs, response: response, }, internals.cacheTTL); + if (response.headers['set-cookie']) { + response.headers['set-cookie'] = Utils.stripDomainFromCookies(response.headers['set-cookie']); + } + return callback(null, internals.getPencilResponse(data, request, response, configuration)); }); }