Skip to content

Commit 318a0b0

Browse files
committed
fix: update regex to include resetpassword guid & add missing condition in refreshInterval
1 parent 9a36db4 commit 318a0b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/hooks/useUser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ export const useUser = ({
5858
initialData,
5959
}: { id?: number; initialData?: User } = {}): UserHookResponse => {
6060
const router = useRouter();
61-
const isAuthPage = /^\/(login|setup|resetpassword)/.test(router.pathname);
61+
const isAuthPage = /^\/(login|setup|resetpassword(?:\/|$))/.test(
62+
router.pathname
63+
);
6264

6365
const {
6466
data,
6567
error,
6668
mutate: revalidate,
6769
} = useSWR<User>(id ? `/api/v1/user/${id}` : `/api/v1/auth/me`, {
6870
fallbackData: initialData,
69-
refreshInterval: 30000,
71+
refreshInterval: !isAuthPage ? 30000 : 0,
7072
revalidateOnFocus: !isAuthPage,
7173
revalidateOnMount: !isAuthPage,
7274
revalidateOnReconnect: !isAuthPage,

0 commit comments

Comments
 (0)