Pkg: Nextjs v9.4.0 gives 404 for static pages when pkg-ed

Created on 26 May 2020  路  7Comments  路  Source: vercel/pkg

Bug report

Describe the bug

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

To Reproduce

  1. Go to this repo
  2. On master branch run yarn install, yarn build, yarn pkg (or pkg-macos)
  3. Execute ./pkg/test to run the app in the self contained server
  4. Notice that we cannot access the localhost:3000 or the localhost:3000/static page but we can access the localhost:3000/ssr which is a server side rendered page

Expected behavior

The expected behavior is that all pages (localhost:3000, localhost:3000/static, localhost:3000/ssr) render normally.

System information

OS: [macOS, linux]
Version of Next.js: [9.4.0]
Version of Node.js: [10]

Additional context

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

Most helpful comment

it should work if you add an empty getStaticProps to the page:

export const getStaticProps = async ()=>{return {props:{}}}

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nilesh0101 picture Nilesh0101  路  4Comments

gillez picture gillez  路  4Comments

ydubois-fr picture ydubois-fr  路  4Comments

hellower picture hellower  路  3Comments

Admiral-Enigma picture Admiral-Enigma  路  3Comments