Unverified Commit ec0d1661 authored by Joseph's avatar Joseph Committed by GitHub

docs: fix proxy matcher overflow (#85337)

Also closes: https://github.com/vercel/next.js/issues/85344
parent 0bcdbe48
...@@ -22,10 +22,7 @@ Some common scenarios where Proxy is effective include: ...@@ -22,10 +22,7 @@ Some common scenarios where Proxy is effective include:
- Rewriting to different pages based on A/B tests or experiments - Rewriting to different pages based on A/B tests or experiments
- Modifying headers for all pages or a subset of pages - Modifying headers for all pages or a subset of pages
Proxy is _not_ a good fit for: Proxy is _not_ intended for slow data fetching. While Proxy can be helpful for [optimistic checks](/docs/app/guides/authentication#optimistic-checks-with-proxy-optional) such as permission-based redirects, it should not be used as a full session management or authorization solution.
- Slow data fetching
- Session management
Using fetch with `options.cache`, `options.next.revalidate`, or `options.next.tags`, has no effect in Proxy. Using fetch with `options.cache`, `options.next.revalidate`, or `options.next.tags`, has no effect in Proxy.
......
...@@ -1121,7 +1121,7 @@ While Proxy can be useful for initial checks, it should not be your only line of ...@@ -1121,7 +1121,7 @@ While Proxy can be useful for initial checks, it should not be your only line of
> **Tips**: > **Tips**:
> >
> - In Proxy, you can also read cookies using `req.cookies.get('session').value`. > - In Proxy, you can also read cookies using `req.cookies.get('session').value`.
> - Proxy uses the [Edge Runtime](/docs/app/api-reference/edge), check if your Auth library and session management library are compatible. > - Proxy uses the Node.js runtime, check if your Auth library and session management library are compatible. You may need to use [Middleware](https://github.com/vercel/next.js/blob/v15.5.6/docs/01-app/03-api-reference/03-file-conventions/middleware.mdx) if your Auth library only supports [Edge Runtime](/docs/app/api-reference/edge)
> - You can use the `matcher` property in the Proxy to specify which routes Proxy should run on. Although, for auth, it's recommended Proxy runs on all routes. > - You can use the `matcher` property in the Proxy to specify which routes Proxy should run on. Although, for auth, it's recommended Proxy runs on all routes.
<AppOnly> <AppOnly>
......
...@@ -80,7 +80,18 @@ export const config = { ...@@ -80,7 +80,18 @@ export const config = {
} }
``` ```
Additionally, the `matcher` option supports complex path specifications through regular expressions, such as `matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)']`, enabling precise control over which paths to include or exclude. Additionally, the `matcher` option supports complex path specifications using regular expressions. For example, you can exclude certain paths with a regular expression matcher:
```js filename="proxy.js"
export const config = {
matcher: [
// Exclude API routes, static files, image optimizations, and .png files
'/((?!api|_next/static|_next/image|.*\\.png$).*)',
],
}
```
This enables precise control over which paths to include or exclude.
The `matcher` option accepts an array of objects with the following keys: The `matcher` option accepts an array of objects with the following keys:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment