Next.js prefetches book.json, but page has url books, so Router will render page with empty props.
Try reload the current page, it will print correct props. Only client-side navigation does not work.
Current vs. Expected behavior
Expected: When using client-side navigation (for route which has rewrite, middleware and dynamic SSG), it should work.
Current: Client-side navigation does not work, page has empty props. Hard refresh has correct props.
Verify canary release
[X] I verified that the issue exists in the latest Next.js canary release
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
After upgrade to Next 13, it stopped working. Also tested on 14 and 14-canary.
It works correctly on localhost, but not on Vercel.
It only does not work when using combination of SSG dynamic page with middleware and Next config rewrite.
If I remove middleware.ts (which has only Response.next()), it will start working as expected.
Link to the code that reproduces this issue
https://github.com/jkondela/next-rewrites-repro
To Reproduce
book.json
, but page has urlbooks
, so Router will render page with empty props.Current vs. Expected behavior
Expected: When using client-side navigation (for route which has rewrite, middleware and dynamic SSG), it should work. Current: Client-side navigation does not work, page has empty props. Hard refresh has correct props.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
Data fetching (gS(S)P, getInitialProps), Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
After upgrade to Next 13, it stopped working. Also tested on 14 and 14-canary.
It works correctly on localhost, but not on Vercel.
It only does not work when using combination of SSG dynamic page with middleware and Next config rewrite. If I remove middleware.ts (which has only
Response.next()
), it will start working as expected.