Investigate delaying asPath values for all build-time exported pages
See original GitHub issueWhen a page is exported at build time from either the automatic static optimization or from leveraging getStaticProps
the asPath
will initially be the pathname
since it is the information we have for what the URL should be when visiting the page.
On the client we currently delay updating the asPath
for dynamic pages that leverage the automatic static optimization to prevent a hydration mismatch. We should investigate applying this behavior for all build-time exported pages since they can all encounter a hydration mismatch if rewritten to using the rewrites feature and asPath
is used while rendering the page.
Original issue opened here https://github.com/vercel/next.js/issues/17113 which was initially thought to be related to GS(S)P asPath
resolving but is not since the reproduction provided only leverages pages that are automatically statically optimized without GS(S)P methods.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (5 by maintainers)
Top GitHub Comments
@nghiepit this issue doesn’t address that, we can’t know the end
asPath
value for automatically statically optimized pages at build time unless you usegetStaticProps
withgetStaticPaths
Hi @ijjk
If
asPath
incorrect on the server-side this is bad news for SEO.Some meta tags will be affected:
og:url
,rel:canonical
,...
It will very difficult to calculate the URL correctly without theasPath
.