question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSG with rewrite not getting passed page props for second rerender client side

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
Binaries:
  Node: 14.19.1
  npm: 8.10.0
  Yarn: 1.22.19
  pnpm: 6.32.11
Relevant packages:
  next: 12.2.6-canary.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome 104.0.5112.79

How are you deploying your application? (if relevant)

vercel

Describe the Bug

When using SSG page with an afterFiles rewrite and a redirect on vercel infrastructure only the page initially is passed the page props from getStaticProps, but a client side rerender no longer is passed the page props.

This is similar to https://github.com/vercel/next.js/issues/38794 with one addition of the redirect.

Expected Behavior

The page props should be passed on every page re-render

Link to reproduction

https://github.com/wweaver/next-playground

To Reproduce

  1. Create an SSG page with getStaticProps that passes page props
  2. Add an afterFiles rewrite that will reroute to the SSG page
  3. Add a redirect that will redirect the false reroute back

Essentially look at the next.config.js for the redriects and rewrites. From previous I think it also has to do with the trailingSlash option and middleware being used. So it’s a very specific bug.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wweavercommented, Aug 23, 2022

We did end up removing the redirect to fix the issue and we had an alternate solution to do the redirect. I left this open because it still seems like a bug. It’s not a rush for us any longer.

0reactions
wweavercommented, Dec 16, 2022

@ijjk i haven’t been able to reproduce in the playground app that I have so I haven’t opened a bug ticket. I’m still trying to pinpoint what’s going on with the new issue when upgrading to nextjs 13.

I’ll look again on Monday

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refreshing Server-Side Props - Next.js - Josh W Comeau
js to re-fetch the data, on demand, without doing a hard refresh of the whole page? In this short tutorial, I'll share the...
Read more >
Next.js Redirect from / to another page - Stack Overflow
client side rendering after SSR: we use props passed by getInitialProps to tell if the user is allowed, directly at first render.
Read more >
Data Fetching: getStaticProps - Next.js
When combined with Incremental Static Regeneration, getStaticProps will run in the background while the stale page is being revalidated, and the fresh page...
Read more >
SSR | TanStack Query Docs
React Query supports two ways of prefetching data on the server and passing that to ... with <Hydrate> and pass it the dehydratedState...
Read more >
Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
getStaticProps allows you to pass data to the pages at build time. ... Server-Side Rendering - Being able to pre-render React components on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found