Skip to content

Commit

Permalink
fix(ui): fix login redirect failed when basehref is set
Browse files Browse the repository at this point in the history
Signed-off-by: henry.liu <[email protected]>
  • Loading branch information
lsq645599166 committed Dec 19, 2024
1 parent d7ccf47 commit 086bc71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ui/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {AuthSettings} from './shared/models';
import {PKCEVerification} from './login/components/pkce-verify';
import {getPKCERedirectURI, pkceLogin} from './login/components/utils';
import {SystemLevelExtension} from './shared/services/extensions-service';
import {getBase} from './utils';

services.viewPreferences.init();
const bases = document.getElementsByTagName('base');
const base = bases.length > 0 ? bases[0].getAttribute('href') || '/' : '/';
const base = getBase();
export const history = createBrowserHistory({basename: base});
requests.setBaseHRef(base);

Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/login/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {AppContext} from '../../shared/context';
import {AuthSettings} from '../../shared/models';
import {services} from '../../shared/services';
import {getPKCERedirectURI, pkceLogin} from './utils';
import {getBase} from '../../utils';

require('./login.scss');

Expand Down Expand Up @@ -135,7 +136,8 @@ 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);
const base = getBase();
this.appContext.apis.navigation.goto(url.pathname.slice(base.length - 1) + url.search);
} else {
this.appContext.apis.navigation.goto('/applications');
}
Expand Down
5 changes: 5 additions & 0 deletions ui/src/app/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const getBase = () => {
const bases = document.getElementsByTagName('base');

return bases.length > 0 ? bases[0].getAttribute('href') || '/' : '/';
};

0 comments on commit 086bc71

Please sign in to comment.