KEMBAR78
docs: Replace Middleware docs to Proxy by devjiwonchoi · Pull Request #84709 · vercel/next.js · GitHub
Skip to content

Conversation

@devjiwonchoi
Copy link
Member

@devjiwonchoi devjiwonchoi commented Oct 9, 2025

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.2
  • errors/beta-middleware.mdx - It's an error when using middleware before v12.2
  • errors/returning-response-body.mdx - Legacy behavior from versions < v12.2

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Oct 9, 2025
Copy link
Member Author

devjiwonchoi commented Oct 9, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

Hi there 👋

It looks like this PR introduces broken links to the docs, please take a moment to fix them before merging:

Broken link Type File
/docs/app/getting-started/#middleware link /docs/01-app/03-api-reference/03-file-conventions/middleware.mdx
/docs/app/guides/self-hosting#proxy hash /docs/01-app/03-api-reference/03-file-conventions/proxy.mdx

Thank you 🙏

@devjiwonchoi devjiwonchoi changed the title Clean-clone Middleware docs for Proxy docs: Clone Middleware docs for Proxy Oct 9, 2025
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_split_get_started_route_handlers_and_middleware_to_route_handlers_and_proxy_ branch from 75f6ec0 to a3cbfa4 Compare October 16, 2025 16:36
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_clone_middleware_docs_for_proxy branch from ba8255a to 1b7ab72 Compare October 16, 2025 16:36
@devjiwonchoi devjiwonchoi marked this pull request as ready for review October 16, 2025 16:38
})
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.
Copy link
Contributor

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.

Suggested change
// 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

Fix in Graphite


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! 🎉
Copy link
Collaborator

@icyJoseph icyJoseph Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nextUrl.searchParams.delete('key') // <-- this is now possible! 🎉
nextUrl.searchParams.delete('key') // <-- this is now possible!

No emojis ~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏 yes haha

@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_split_get_started_route_handlers_and_middleware_to_route_handlers_and_proxy_ branch from a3cbfa4 to d12cb23 Compare October 17, 2025 01:13
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_clone_middleware_docs_for_proxy branch from 1b7ab72 to 91f1897 Compare October 17, 2025 01:13

## Version history

| Version | Changes |
Copy link
Collaborator

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

@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_split_get_started_route_handlers_and_middleware_to_route_handlers_and_proxy_ branch from d12cb23 to 0091bdd Compare October 17, 2025 10:41
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_clone_middleware_docs_for_proxy branch from cde5fd5 to e24ff30 Compare October 17, 2025 10:41
devjiwonchoi added a commit that referenced this pull request Oct 17, 2025
- 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.
Copy link
Collaborator

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

Copy link
Member Author

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

@devjiwonchoi
Copy link
Member Author

devjiwonchoi commented Oct 17, 2025

Noticed the docs link validation was accurate 😅 should we replace the doc below at #84964?

## Middleware
[Middleware](/docs/app/api-reference/file-conventions/middleware) works self-hosted with zero configuration when deploying using `next start`. Since it requires access to the incoming request, it is not supported when using a [static export](/docs/app/guides/static-exports).
Middleware uses the [Edge runtime](/docs/app/api-reference/edge), a subset of all available Node.js APIs to help ensure low latency, since it may run in front of every route or asset in your application. If you do not want this, you can use the [full Node.js runtime](/blog/next-15-2#nodejs-middleware-experimental) to run Middleware.

EDIT: Added to #84964

@devjiwonchoi devjiwonchoi changed the title docs: Clone Middleware docs for Proxy docs: Replace Middleware docs to Proxy Oct 17, 2025
@devjiwonchoi devjiwonchoi changed the base branch from jiwon/10-09-docs_split_get_started_route_handlers_and_middleware_to_route_handlers_and_proxy_ to graphite-base/84709 October 17, 2025 13:40
devjiwonchoi and others added 3 commits October 17, 2025 16:01
- Example of "Set-Cookie:vercel=fast;path=/"
- keep the Middleware in the history
Co-authored-by: Joseph <sephxd1234@gmail.com>
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-09-docs_clone_middleware_docs_for_proxy branch from c6b1b85 to 8965f0c Compare October 17, 2025 14:04
@devjiwonchoi devjiwonchoi changed the base branch from graphite-base/84709 to canary October 17, 2025 14:04
@devjiwonchoi devjiwonchoi merged commit 71ce95d into canary Oct 17, 2025
146 of 147 checks passed
@devjiwonchoi devjiwonchoi deleted the jiwon/10-09-docs_clone_middleware_docs_for_proxy branch October 17, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants