I use pkg to package my nextjs app.
When I upgraded to version 9.4.0 from 9.3.6 the static pages I tried to access were all redirecting to the 404 page.
SSR pages work as expected on 9.4.0.
Also everything works as expected on dev mode
The expected behavior is that all pages (localhost:3000, localhost:3000/static, localhost:3000/ssr) render normally.
OS: [macOS, linux]
Version of Next.js: [9.4.0]
Version of Node.js: [10]
If you checkout branch 9.3.6 which has the previous version of nextjs and perform the same steps you will notice that everything works as expected
If it helps the error started after this commit on nextjs
https://github.com/vercel/next.js/pull/12026/commits/2e1044f85d1413baf8e0d0e14944632f47125335
it should work if you add an empty getStaticProps to the page:
export const getStaticProps = async ()=>{return {props:{}}}
@tronjsdev thanks for your answer. I am aware of this and this is the workaround we currently follow. But it shouldn't be the case. Also nextjs doesn't let you put getInitialProps to 404 page. 404 needs to be static. So we currently don't have a custom 404 page.
maybe you're confusing between getInitialProps and getStaticProps or somethings I was missing?
Doesn't nextjs will pre-render the page with getStaticProps declared and therefore it should be static?
Thanks @tronjsdev indeed I misunderstood what you said earlier. It seems to work now that the pages are SSG instead of static.
Thanks for taking the time to respond!
Why is this closed? As far as I'm aware, you only found a workaround, but no solution yet. So this is still a bug which should get fixed, so what about re-opening this issue?
Why is this closed? As far as I'm aware, you only found a workaround, but no solution yet. So this is still a bug which should get fixed, so what about re-opening this issue?
This is a bug introduced by the upgrade of NextJS. So my thinking is that I shouldn't blame pkg for this issue. I opened the issue both in pkg and NextJS repos. In NextJS my issue was converted into a discussion by the maintainers so there isn't much a can do about it.
Most helpful comment
it should work if you add an empty getStaticProps to the page: