fix 404 problem

This commit is contained in:
keyan 2023-08-01 12:45:46 -05:00
parent 2732e3bb83
commit a426c8b539
1 changed files with 4 additions and 3 deletions

View File

@ -31,14 +31,15 @@ function MyApp ({ Component, pageProps: { ...props } }) {
const router = useRouter()
useEffect(() => {
if (router.query.nodata || !router.isReady ||
Component?.name === 'Custom404') return
// HACK: 'cause there's no way to tell Next to skip SSR
// So every page load, we modify the route in browser history
// to point to the same page but without SSR, ie ?nodata=true
// this nodata var will get passed to the server on back/foward and
// 1. prevent data from reloading and 2. perserve scroll
// (2) is not possible while intercepting nav with beforePopState
if (router.query.nodata || !router.isReady) return
router.replace({
pathname: router.pathname,
query: { ...router.query, nodata: true }
@ -48,7 +49,7 @@ function MyApp ({ Component, pageProps: { ...props } }) {
throw e
}
})
}, [router.pathname, router.query])
}, [router.pathname, router.query, Component?.name])
/*
If we are on the client, we populate the apollo cache with the