This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 3646cdf2d0 [#9354] fix(web): fix redirect metalake issue (#9355)
3646cdf2d0 is described below
commit 3646cdf2d095c951626c6a016305e92ca16f3764
Author: Qian Xia <[email protected]>
AuthorDate: Wed Dec 3 12:31:35 2025 +0800
[#9354] fix(web): fix redirect metalake issue (#9355)
### What changes were proposed in this pull request?
fix redirect metalake issue
### Why are the changes needed?
Under the same session, the pathname '/' may not be automatically
redirected to 'metalakes' via router replacement.
Fix: #9354
### Does this PR introduce _any_ user-facing change?
N/A
### How was this patch tested?
manually
---
web/web/src/lib/provider/session.js | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/web/web/src/lib/provider/session.js
b/web/web/src/lib/provider/session.js
index 652de1e8fd..ebd9df1575 100644
--- a/web/web/src/lib/provider/session.js
+++ b/web/web/src/lib/provider/session.js
@@ -66,20 +66,19 @@ const AuthProvider = ({ children }) => {
const goToMetalakeListPage = () => {
try {
- const pathname = window.location.pathname
- const doneFlag = sessionStorage.getItem('authInitDone')
+ let pathname = window.location.pathname
- if (!doneFlag) {
- sessionStorage.setItem('authInitDone', 'true')
-
- if (pathname === '/' || pathname === '/ui' || pathname === '/ui/') {
- router.replace('/metalakes')
- } else {
- router.replace(pathname + window.location.search)
- }
+ // Remove /ui prefix since Next.js basePath will add it automatically
+ if (pathname.startsWith('/ui')) {
+ pathname = pathname.slice(3) || '/'
+ }
+ if (pathname === '/' || pathname === '') {
+ router.replace('/metalakes')
+ } else {
+ router.replace(pathname + window.location.search)
}
} catch (e) {
- router.push('/metalakes')
+ router.replace('/metalakes')
}
}