Skip to content

Commit 9c9e793

Browse files
authored
Add middleware to routes order doc (#84618)
This adds `middleware` in the routes order to clarify where it comes in priority.
1 parent b0780f2 commit 9c9e793

File tree

1 file changed

+5
-4
lines changed
  • docs/01-app/03-api-reference/05-config/01-next-config-js

1 file changed

+5
-4
lines changed

docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ The order Next.js routes are checked is:
9090

9191
1. [headers](/docs/app/api-reference/config/next-config-js/headers) are checked/applied
9292
2. [redirects](/docs/app/api-reference/config/next-config-js/redirects) are checked/applied
93-
3. `beforeFiles` rewrites are checked/applied
94-
4. static files from the [public directory](/docs/app/api-reference/file-conventions/public-folder), `_next/static` files, and non-dynamic pages are checked/served
95-
5. `afterFiles` rewrites are checked/applied, if one of these rewrites is matched we check dynamic routes/static files after each match
96-
6. `fallback` rewrites are checked/applied, these are applied before rendering the 404 page and after dynamic routes/all static assets have been checked. If you use [fallback: true/'blocking'](/docs/pages/api-reference/functions/get-static-paths#fallback-true) in `getStaticPaths`, the fallback `rewrites` defined in your `next.config.js` will _not_ be run.
93+
3. [middleware](/docs/app/api-reference/file-conventions/middleware)
94+
4. `beforeFiles` rewrites are checked/applied
95+
5. static files from the [public directory](/docs/app/api-reference/file-conventions/public-folder), `_next/static` files, and non-dynamic pages are checked/served
96+
6. `afterFiles` rewrites are checked/applied, if one of these rewrites is matched we check dynamic routes/static files after each match
97+
7. `fallback` rewrites are checked/applied, these are applied before rendering the 404 page and after dynamic routes/all static assets have been checked. If you use [fallback: true/'blocking'](/docs/pages/api-reference/functions/get-static-paths#fallback-true) in `getStaticPaths`, the fallback `rewrites` defined in your `next.config.js` will _not_ be run.
9798

9899
</AppOnly>
99100

0 commit comments

Comments
 (0)