-
Notifications
You must be signed in to change notification settings - Fork 29.7k
docs: Replace Middleware docs to Proxy #84709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Replace Middleware docs to Proxy #84709
Conversation
|
Hi there 👋 It looks like this PR introduces broken links to the docs, please take a moment to fix them before merging:
Thank you 🙏 |
75f6ec0 to
a3cbfa4
Compare
ba8255a to
1b7ab72
Compare
| }) | ||
| cookie = response.cookies.get('vercel') | ||
| console.log(cookie) // => { name: 'vercel', value: 'fast', Path: '/' } | ||
| // The outgoing response will have a `Set-Cookie:vercel=fast;path=/test` header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment in the cookie example doesn't match the code implementation. The code sets the cookie path to '/' on line 321, but the comment incorrectly states the outgoing response will have path=/test. The comment should be updated to Set-Cookie:vercel=fast;path=/ to accurately reflect the code behavior.
| // The outgoing response will have a `Set-Cookie:vercel=fast;path=/test` header. | |
| // The outgoing response will have a `Set-Cookie:vercel=fast;path=/` header. |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
|
||
| export default function proxy(request: NextRequest) { | ||
| const nextUrl = request.nextUrl | ||
| nextUrl.searchParams.delete('key') // <-- this is now possible! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| nextUrl.searchParams.delete('key') // <-- this is now possible! 🎉 | |
| nextUrl.searchParams.delete('key') // <-- this is now possible! |
No emojis ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a clean copy from middleware docs 😂 Remove from both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 yes haha
a3cbfa4 to
d12cb23
Compare
1b7ab72 to
91f1897
Compare
|
|
||
| ## Version history | ||
|
|
||
| | Version | Changes | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can keep the Middleware in the history here, and add a v16 row, with the renaming
If one uses v14, or v13, it'll be middleware
d12cb23 to
0091bdd
Compare
cde5fd5 to
e24ff30
Compare
| - app/api-reference/functions/next-response | ||
| --- | ||
|
|
||
| The `proxy.js|ts` file is used to write [Proxy](/docs/app/getting-started/route-handlers-and-proxy#proxy) and run code on the server before a request is completed. Then, based on the incoming request, you can modify the response by rewriting, redirecting, modifying the request or response headers, or responding directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this link is gonna be broken, since proxy is separate from route handlers in: https://github.com/vercel/next.js/pull/84708/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch, will replace
|
Noticed the docs link validation was accurate 😅 should we replace the doc below at #84964? next.js/docs/01-app/02-guides/self-hosting.mdx Lines 25 to 29 in 8bc8dc3
EDIT: Added to #84964 |
Co-authored-by: Joseph <sephxd1234@gmail.com>
- Example of "Set-Cookie:vercel=fast;path=/" - keep the Middleware in the history
Co-authored-by: Joseph <sephxd1234@gmail.com>
0091bdd to
fd8b4c5
Compare
c6b1b85 to
8965f0c
Compare

Note
Best reviewed by each commit for better diff view.
This PR clones the Middleware docs for Proxy and removes the Middleware docs.
Did not clone the list of docs:
errors/middleware-upgrade.mdx- It's a middleware upgrade guide from v12.2errors/beta-middleware.mdx- It's an error when using middleware before v12.2errors/returning-response-body.mdx- Legacy behavior from versions < v12.2