fix 404 problem
This commit is contained in:
parent
2732e3bb83
commit
a426c8b539
@ -31,14 +31,15 @@ function MyApp ({ Component, pageProps: { ...props } }) {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (router.query.nodata || !router.isReady ||
|
||||||
|
Component?.name === 'Custom404') return
|
||||||
|
|
||||||
// HACK: 'cause there's no way to tell Next to skip SSR
|
// HACK: 'cause there's no way to tell Next to skip SSR
|
||||||
// So every page load, we modify the route in browser history
|
// So every page load, we modify the route in browser history
|
||||||
// to point to the same page but without SSR, ie ?nodata=true
|
// 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
|
// this nodata var will get passed to the server on back/foward and
|
||||||
// 1. prevent data from reloading and 2. perserve scroll
|
// 1. prevent data from reloading and 2. perserve scroll
|
||||||
// (2) is not possible while intercepting nav with beforePopState
|
// (2) is not possible while intercepting nav with beforePopState
|
||||||
if (router.query.nodata || !router.isReady) return
|
|
||||||
|
|
||||||
router.replace({
|
router.replace({
|
||||||
pathname: router.pathname,
|
pathname: router.pathname,
|
||||||
query: { ...router.query, nodata: true }
|
query: { ...router.query, nodata: true }
|
||||||
@ -48,7 +49,7 @@ function MyApp ({ Component, pageProps: { ...props } }) {
|
|||||||
throw e
|
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
|
If we are on the client, we populate the apollo cache with the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user