🐛 404 페이지 라우팅 조건 수정

This commit is contained in:
shinmj
2021-10-29 17:39:33 +09:00
parent b6ae0c38a9
commit fad1905078

View File

@@ -95,7 +95,7 @@ const App = ({ component: Component, ...pageProps }: AppProps) => {
) )
useEffect(() => { useEffect(() => {
if (mounted && flatMenus) { if (mounted && data?.length > 0 && flatMenus?.length > 0) {
let path = let path =
router.asPath.indexOf('?') === -1 router.asPath.indexOf('?') === -1
? router.asPath ? router.asPath
@@ -110,7 +110,7 @@ const App = ({ component: Component, ...pageProps }: AppProps) => {
} }
// 권한 없는 페이지 대해 호출이 있으면 404로 redirect // 권한 없는 페이지 대해 호출이 있으면 404로 redirect
if (!authPage && flatMenus.length > 0 && !current) { if (!authPage && !current) {
if (!PUBLIC_PAGES.includes(router.asPath)) { if (!PUBLIC_PAGES.includes(router.asPath)) {
router.push('/404') router.push('/404')
} }
@@ -118,7 +118,7 @@ const App = ({ component: Component, ...pageProps }: AppProps) => {
setCurrentMenus(current) setCurrentMenus(current)
} }
}, [router, mounted, flatMenus]) }, [router, mounted, flatMenus, data])
if (loading) { if (loading) {
return <Loader /> return <Loader />
@@ -128,6 +128,10 @@ const App = ({ component: Component, ...pageProps }: AppProps) => {
return null return null
} }
if (data?.length <= 0 || flatMenus?.length <= 0) {
return <Loader />
}
return errorPage || naverLoginCallbackPage ? ( return errorPage || naverLoginCallbackPage ? (
<Wrapper> <Wrapper>
<Component {...pageProps} /> <Component {...pageProps} />