Skip to content

Commit 6e86384

Browse files
authored
fix(Authentication): remove basename (#3042)
1 parent f68c877 commit 6e86384

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/containers/Authentication/Authentication.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {Button, Link as ExternalLink, Icon, TextInput} from '@gravity-ui/uikit';
55
import {useHistory, useLocation} from 'react-router-dom';
66

77
import {parseQuery} from '../../routes';
8+
import {basename} from '../../store';
89
import {authenticationApi} from '../../store/reducers/authentication/authentication';
910
import {useLoginWithDatabase} from '../../store/reducers/capabilities/hooks';
1011
import {cn} from '../../utils/cn';
@@ -42,7 +43,19 @@ function Authentication({closable = false}: AuthenticationProps) {
4243
// history navigates relative to origin
4344
// so we remove origin to make it work properly
4445
const url = new URL(decodedUrl);
45-
path = url.pathname + url.search;
46+
let pathname = url.pathname;
47+
48+
// Remove basename from pathname since history.replace expects paths relative to basename
49+
if (basename && pathname.startsWith(basename)) {
50+
pathname = pathname.slice(basename.length);
51+
}
52+
53+
// Ensure pathname starts with /
54+
if (pathname && !pathname.startsWith('/')) {
55+
pathname = '/' + pathname;
56+
}
57+
58+
path = pathname + url.search;
4659
}
4760
return path;
4861
}, [returnUrl]);

0 commit comments

Comments
 (0)