Skip to content

Commit 2618ccc

Browse files
fix: login return_url doesn't work with custom server paths (cherry-pick #21588) (#21603)
Signed-off-by: Alexander Matyushentsev <[email protected]> Co-authored-by: Alexander Matyushentsev <[email protected]>
1 parent 38e02ab commit 2618ccc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ui/src/app/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export class App extends React.Component<
235235
}
236236

237237
public getChildContext() {
238-
return {history, apis: {popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager}};
238+
return {history, apis: {popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager, baseHref: base}};
239239
}
240240

241241
private async subscribeUnauthorized() {

ui/src/app/login/components/login.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ export class Login extends React.Component<RouteComponentProps<{}>, State> {
136136
this.setState({loginInProgress: false});
137137
if (returnURL) {
138138
const url = new URL(returnURL);
139-
this.appContext.apis.navigation.goto(url.pathname + url.search);
139+
let redirectURL = url.pathname + url.search;
140+
// return url already contains baseHref, so we need to remove it
141+
if (this.appContext.apis.baseHref != '/' && redirectURL.startsWith(this.appContext.apis.baseHref)) {
142+
redirectURL = redirectURL.substring(this.appContext.apis.baseHref.length);
143+
}
144+
this.appContext.apis.navigation.goto(redirectURL);
140145
} else {
141146
this.appContext.apis.navigation.goto('/applications');
142147
}

0 commit comments

Comments
 (0)