Skip to content

Commit

Permalink
🐛 fix: fix clerk UNAUTHORIZED auth error (lobehub#2907)
Browse files Browse the repository at this point in the history
* 🐛 fix: fix clerk auth error

* 🐛 fix: fix clerk auth error

* 🐛 fix: prefetch error translation ns
arvinxx authored Jun 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 8e1a553 commit bb33ba4
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/layout/GlobalProvider/StoreInitialization.tsx
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import { useRouter, useSearchParams } from 'next/navigation';
import { memo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { createStoreUpdater } from 'zustand-utils';

import { LOBE_URL_IMPORT_NAME } from '@/const/url';
@@ -14,8 +15,10 @@ import { useUserStore } from '@/store/user';
import { authSelectors } from '@/store/user/selectors';

const StoreInitialization = memo(() => {
const router = useRouter();
// prefetch error ns to avoid don't show error content correctly
useTranslation('error');

const router = useRouter();
const [isLogin, useInitUserState, importUrlShareSettings] = useUserStore((s) => [
authSelectors.isLogin(s),
s.useInitUserState,
@@ -57,21 +60,14 @@ const StoreInitialization = memo(() => {
importUrlShareSettings(searchParam);
}, [searchParam]);

// useEffect(() => {
// router.prefetch('/chat');
// router.prefetch('/market');
//
// if (mobile) {
// router.prefetch('/me');
// router.prefetch('/chat/settings');
// router.prefetch('/settings/common');
// router.prefetch('/settings/agent');
// router.prefetch('/settings/sync');
// } else {
// router.prefetch('/chat/settings/modal');
// router.prefetch('/settings/modal');
// }
// }, [router, mobile]);
useEffect(() => {
if (mobile) {
router.prefetch('/me');
} else {
router.prefetch('/chat/settings/modal');
router.prefetch('/settings/modal');
}
}, [router, mobile]);

return null;
});
2 changes: 2 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ export const config = {
'/(api|trpc)(.*)',
// include the /
'/',
'/chat(.*)',
// ↓ cloud ↓
],
};

0 comments on commit bb33ba4

Please sign in to comment.