Skip to content

Commit

Permalink
Fixed weird redirect issues on production
Browse files Browse the repository at this point in the history
  • Loading branch information
bherr2 committed Jul 29, 2022
1 parent 483752b commit 863e482
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/server-auth0.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ const SESSION_SECRET = process.env.SESSION_SECRET || 'cow-abunga d00d';
const BASE_URL = process.env.BASE_URL || '';

const auth0Config = {
authRequired: true,
authRequired: false,
auth0Logout: true,
secret: process.env.AUTH0_SECRET,
baseURL: process.env.BASE_URL,
clientID: process.env.AUTH0_CLIENT_ID,
issuerBaseURL: process.env.AUTH0_ISSUER_URL
issuerBaseURL: process.env.AUTH0_ISSUER_URL,
routes: {
postLogoutRedirect: '/client/a2agc/'
}
}

// Override remote-user login token
Expand Down Expand Up @@ -72,10 +75,14 @@ function ensureAuth(req, res, next) {
return next();
}
} else {
res.redirect(BASE_URL + '/login');
res.redirect(BASE_URL + '/login-home');
}
}

app.get('/login-home', (req, res) => {
res.oidc.login({ returnTo: '/client/a2agc/' });
});

// Host the protected site directory, allowing only authorized users to view
app.use('/', ensureAuth, express.static(abspath(PROTECTED_DIR)));

Expand Down

0 comments on commit 863e482

Please sign in to comment.