SSG with rewrite not getting passed page props for second rerender client side
See original GitHub issueVerify 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
- https://github.com/wweaver/next-playground
- https://next-playground-git-main-wweaver.vercel.app/river/
- Create an SSG page with getStaticProps that passes page props
- Add an afterFiles rewrite that will reroute to the SSG page
- 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:
- Created a year ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@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