You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/03-file-conventions/middleware.mdx
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,17 @@ export const config = {
48
48
49
49
## Exports
50
50
51
+
> **Note**
52
+
> Place `middleware.{js,ts}` at the **project root** or **`/src` root**:
53
+
>
54
+
> ```
55
+
> /middleware.ts ✅
56
+
> /src/middleware.ts ✅
57
+
> /app/middleware.ts ❌ (not supported)
58
+
> ```
59
+
>
60
+
> If the file is not at root, Next.js will not load it. See also: [Matcher config](https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher).
61
+
51
62
### Middleware function
52
63
53
64
The file must export a single function, either as a default export or named `middleware`. Note that multiple middleware from the same file are not supported.
0 commit comments