fix: login return_url doesn't work with custom server paths (#21588)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
This commit is contained in:
Alexander Matyushentsev 2025-01-21 09:22:50 -08:00 committed by GitHub
parent 55aab6efb6
commit eed70eed6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -235,7 +235,7 @@ export class App extends React.Component<
}
public getChildContext() {
return {history, apis: {popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager}};
return {history, apis: {popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager, baseHref: base}};
}
private async subscribeUnauthorized() {

View file

@ -135,7 +135,12 @@ export class Login extends React.Component<RouteComponentProps<{}>, State> {
this.setState({loginInProgress: false});
if (returnURL) {
const url = new URL(returnURL);
this.appContext.apis.navigation.goto(url.pathname + url.search);
let redirectURL = url.pathname + url.search;
// return url already contains baseHref, so we need to remove it
if (this.appContext.apis.baseHref != '/' && redirectURL.startsWith(this.appContext.apis.baseHref)) {
redirectURL = redirectURL.substring(this.appContext.apis.baseHref.length);
}
this.appContext.apis.navigation.goto(redirectURL);
} else {
this.appContext.apis.navigation.goto('/applications');
}