mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-03 00:58:37 +00:00
fix: infinite redirect issue (#583)
This commit is contained in:
parent
d8482f3a13
commit
ae4b95301f
2 changed files with 10 additions and 6 deletions
|
@ -3,14 +3,18 @@ export default defineNuxtRouteMiddleware(async () => {
|
|||
const api = useUserApi();
|
||||
|
||||
if (!ctx.isAuthorized()) {
|
||||
return navigateTo("/");
|
||||
if (window.location.pathname !== "/") {
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx.user) {
|
||||
console.log("Fetching user data");
|
||||
const { data, error } = await api.user.self();
|
||||
if (error) {
|
||||
return navigateTo("/");
|
||||
if (window.location.pathname !== "/") {
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
ctx.user = data.item;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue