Skip to content

Commit

Permalink
DT-6631 fix localhost login
Browse files Browse the repository at this point in the history
  • Loading branch information
sharhio committed Dec 17, 2024
1 parent 939e8d5 commit 5435ee8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/auth/Strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ OICStrategy.prototype.createAuthUrl = function (redirectUri, lang, ssoToken) {

OICStrategy.prototype.createRedirectUrl = function (req) {
const host = req.headers['x-forwarded-host'] || req.headers.host;
if (
process.env.NODE_ENV === "local" &&
req.headers.host === "localhost:3001"
) {
return `http://${host}${this.callbackPath}`.replace("3001", "3000");
}

if (req.secure) {
return `https://${host}${this.callbackPath}`;
}
Expand Down
12 changes: 12 additions & 0 deletions src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ module.exports = function (app) {
createProxyMiddleware({
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;
}
},
}),
);
app.use(
Expand All @@ -35,6 +46,7 @@ module.exports = function (app) {
createProxyMiddleware({
target: 'http://localhost:3001',
changeOrigin: true,
hostRewrite: process.env.NODE_ENV === "development",
})
)
app.use(
Expand Down

0 comments on commit 5435ee8

Please sign in to comment.