Skip to content

Commit be81419

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

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ui/src/app/app.tsx

+1-1
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

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

0 commit comments

Comments
 (0)