diff --git a/src/setupProxy.js b/src/setupProxy.js index 75c5e9e8..1e154846 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -1,12 +1,29 @@ /* eslint-disable */ const { createProxyMiddleware } = require('http-proxy-middleware'); +const setLocalhostCookies = proxyRes => { + if ( + process.env.NODE_ENV === 'development' && + proxyRes.headers.location === 'http://localhost:3000/' && + proxyRes.headers['set-cookie'] !== undefined + ) { + const cookies = proxyRes.headers['set-cookie'].map( + // get browser to set cookie for testing + cookie => cookie.replace('SameSite=None', 'SameSite=Strict; Secure'), + ); + proxyRes.headers["set-cookie"] = cookies; + } +}; + module.exports = function (app) { app.use( '/oid_callback', createProxyMiddleware({ target: 'http://localhost:3001', changeOrigin: true, + onProxyRes: function (proxyRes) { + setLocalhostCookies(proxyRes); + }, }), ); app.use( @@ -15,15 +32,7 @@ module.exports = function (app) { target: 'http://localhost:3001', changeOrigin: true, onProxyRes: function (proxyRes) { - if (process.env.NODE_ENV === "development" && - proxyRes.headers.location === "http://localhost:3000/" && - proxyRes.headers["set-cookie"] !== undefined) { - const cookies = proxyRes.headers["set-cookie"].map( - // get browser to set cookie for testing - (cookie) => cookie.replace("SameSite=None", "SameSite=Strict; Secure") - ); - proxyRes.headers["set-cookie"] = cookies; - } + setLocalhostCookies(proxyRes); }, }), );