Skip to content

Commit

Permalink
fix: login return_url doesn't work with custom server paths (argoproj…
Browse files Browse the repository at this point in the history
…#21588)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Signed-off-by: Brett C. Dudo <brett@dudo.io>
  • Loading branch information
alexmt authored and dudo committed Jan 25, 2025
1 parent 614a0de commit 0cebece
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/login/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 0cebece

Please sign in to comment.