Add note to incremental migration about dynamic routes + fallbacks (#41147)

Addresses this discussion: https://github.com/vercel/next.js/discussions/38839
This commit is contained in:
Lee Robinson 2022-10-03 22:24:35 -05:00 committed by GitHub
parent b56c039ef2
commit ba96b9a4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,8 +33,6 @@ module.exports = {
To learn more about `basePath`, take a look at our [documentation](/docs/api-reference/next.config.js/basepath.md).
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If youre using older versions of Next.js, please upgrade before trying it out.
### Rewrites
The second strategy is to create a new Next.js app that points to the root URL of your domain. Then, you can use [`rewrites`](/docs/api-reference/next.config.js/rewrites.md) inside `next.config.js` to have some subpaths to be proxied to your existing app.
@ -78,7 +76,7 @@ module.exports = {
To learn more about rewrites, take a look at our [documentation](/docs/api-reference/next.config.js/rewrites.md).
> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If youre using older versions of Next.js, please upgrade before trying it out.
> **Note:** If you are incrementally migrating to a dynamic route (e.g. `[slug].js`) and using `fallback: true` or `fallback: 'blocking'` along with a fallback `rewrite`, ensure you consider the case where pages are not found. When Next.js matches the dynamic route it stops checking any further routes. Using `notFound: true` in `getStaticProps` will return the 404 page without applying the fallback `rewrite`. If this is not desired, you can use `getServerSideProps` with `stale-while-revalidate` Cache-Control headers when returning your props. Then, you can _manually_ proxy to your existing backend using something like [http-proxy](https://github.com/vercel/next.js/discussions/38839#discussioncomment-3744442) instead of returning `notFound: true`.
### Micro-Frontends with Monorepos and Subdomains