diff --git a/Parse-Dashboard/app.js b/Parse-Dashboard/app.js index 56ac3146f0..2b4c73fca0 100644 --- a/Parse-Dashboard/app.js +++ b/Parse-Dashboard/app.js @@ -173,7 +173,7 @@ module.exports = function(config, options) { } app.get('/login', csrf(), function(req, res) { - const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1]; + const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1].length > 1 && req.url.split('?redirect=')[1]; if (!users || (req.user && req.user.isAuthenticated)) { return res.redirect(`${mountPath}${redirectURL || 'apps'}`); } @@ -207,7 +207,11 @@ module.exports = function(config, options) { // For every other request, go to index.html. Let client-side handle the rest. app.get('/*', function(req, res) { if (users && (!req.user || !req.user.isAuthenticated)) { - return res.redirect(`${mountPath}login?redirect=${req.url.replace('/login', '')}`); + const redirect = req.url.replace('/login', ''); + if (redirect.length > 1) { + return res.redirect(`${mountPath}login?redirect=${redirect}`); + } + return res.redirect(`${mountPath}login`); } if (users && req.user && req.user.matchingUsername ) { res.append('username', req.user.matchingUsername); diff --git a/src/dashboard/DashboardView.react.js b/src/dashboard/DashboardView.react.js index 4846ae4c72..8402dcc04f 100644 --- a/src/dashboard/DashboardView.react.js +++ b/src/dashboard/DashboardView.react.js @@ -32,9 +32,8 @@ export default class DashboardView extends React.Component { } onRouteChanged() { - const appId = this.context.applicationId; const path = this.props.location?.pathname ?? window.location.pathname; - const route = path.split(appId)[1].split('/')[1]; + const route = path.split('apps')[1].split('/')[2]; if (route !== this.state.route) { this.setState({ route }); } diff --git a/src/login/Login.js b/src/login/Login.js index 967da8b57e..135f5b0079 100644 --- a/src/login/Login.js +++ b/src/login/Login.js @@ -34,7 +34,7 @@ export default class Login extends React.Component { forgot: false, username: sessionStorage.getItem('username') || '', password: sessionStorage.getItem('password') || '', - redirect + redirect: redirect !== '/' ? redirect : undefined }; sessionStorage.clear(); setBasePath(props.path);