Skip to content

Commit

Permalink
Added "negative matcher" documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Sep 6, 2022
1 parent 71ad0dd commit 710da43
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/advanced-features/middleware.md
Expand Up @@ -88,6 +88,22 @@ export const config = {
}
```

You can also create a "negative matcher" that matches all paths except for certain paths:

```js
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - static (static files)
* - favicon.ico (favicon file)
*/
"/((?!api|static|favicon.ico).*)",
],
}
```

> **Note:** The `matcher` values need to be constants so they can be statically analyzed at build-time. Dynamic values such as variables will be ignored.
Configured matchers:
Expand Down

0 comments on commit 710da43

Please sign in to comment.