Skip to content

Commit

Permalink
Update incremental adoption in rewrites doc (#24186)
Browse files Browse the repository at this point in the history
This updates the incremental adoption section in the rewrites docs to mention the new fallback rewrites instead of the no-op rewrite and also points to the incrementally adopting Next.js doc. 

## Documentation / Examples

- [x] Make sure the linting passes

Closes: #23700
Closes: #23699
  • Loading branch information
ijjk authored Apr 18, 2021
1 parent 557ecb0 commit d2b0d43
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions docs/api-reference/next.config.js/rewrites.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,29 +300,27 @@ module.exports = {

### Incremental adoption of Next.js

You can also make Next.js check the application routes before falling back to proxying to the previous website.
You can also have Next.js fall back to proxying to an existing website after checking all Next.js routes.

This way you don't have to change the rewrites configuration when migrating more pages to Next.js

```js
module.exports = {
async rewrites() {
return [
// we need to define a no-op rewrite to trigger checking
// all pages/static files before we attempt proxying
{
source: '/:path*',
destination: '/:path*',
},
{
source: '/:path*',
destination: `https://custom-routes-proxying-endpoint.vercel.app/:path*`,
},
]
return {
fallback: [
{
source: '/:path*',
destination: `https://custom-routes-proxying-endpoint.vercel.app/:path*`,
},
],
}
},
}
```

See additional information on incremental adoption [in the docs here](https://nextjs.org/docs/migrating/incremental-adoption).

### Rewrites with basePath support

When leveraging [`basePath` support](/docs/api-reference/next.config.js/basepath.md) with rewrites each `source` and `destination` is automatically prefixed with the `basePath` unless you add `basePath: false` to the rewrite:
Expand Down

0 comments on commit d2b0d43

Please sign in to comment.