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
fix: check NEXT_DISABLE_NETLIFY_EDGE value rather than if truthy (#1603)
* fix: check NEXT_DISABLE_NETLIFY_EDGE value rather than if truthy
* fix: convert to string compare
* fix: allow unset var behavior to remain
* chore(docs): update middleware docs
* fix: update logic
Co-authored-by: Matt Kane <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/middleware.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,15 @@
1
-
# Using Next 12 middleware on Netlify
1
+
# Using Next.js 12 middleware on Netlify
2
2
3
-
Next 12 introduces a new feature called [Middleware](https://nextjs.org/docs/middleware), in which functions run before
3
+
Next.js 12 introduces a new feature called [Middleware](https://nextjs.org/docs/middleware), in which functions run before
4
4
a request has finished processing. Middleware can be used to modify the request or replace the response. For example, it
5
5
can change headers, rewrite the request path, or return a different response entirely.
6
6
7
7
Next.js Middleware can run either in an edge function (highly recommended for version 12.2+ as ISR will not work
8
8
otherwise) or at the origin. On Netlify, Middleware runs at the origin as part of the normal Next.js server.
9
9
10
-
If you'd like to run Middleware at the edge, set the environment variable `NEXT_USE_NETLIFY_EDGE` to `true`.
10
+
## How to deploy Next.js 12 middleware
11
11
12
-
## How to deploy Next 12 middleware
13
-
14
-
Next 12 Middleware works out of the box with Netlify, and most functions will work unchanged. See
15
-
[the middleware docs](https://nextjs.org/docs/middleware) for details of how to create them. There are however a few
16
-
workarounds that are currently required for some features during the beta period:
12
+
Next.js 12 Middleware works out of the box with Netlify, and most functions will work unchanged. By default, middleware runs using Netlify Edge Functions. For legacy support for running Middleware at the origin, set the environment variable `NEXT_DISABLE_NETLIFY_EDGE` to `true`. Be aware that this will result in slower performance, as all pages that match middleware must use SSR. See [the middleware docs](https://nextjs.org/docs/middleware) for details of how to create Next.js middleware. There are however a few workarounds that are currently required for some features during the beta period:
0 commit comments