Skip to content

chore: migrate from middleware.ts to proxy.ts for Next.js 16 compatib… - #8419

Closed
Faizanahmedsy wants to merge 6 commits into
nodejs:mainfrom
Faizanahmedsy:chore/migrate-to-proxy
Closed

Faizanahmedsy wants to merge 6 commits into
nodejs:mainfrom
Faizanahmedsy:chore/migrate-to-proxy

Conversation

@Faizanahmedsy

@Faizanahmedsy Faizanahmedsy commented Dec 14, 2025 •

Copy link
Copy Markdown

…ility

Migrate from the deprecated middleware.ts file convention to the new proxy.ts convention as required by Next.js 16.0.10.

The middleware file convention has been deprecated and renamed to 'proxy' to better clarify its purpose as a network boundary in front of the app, and to avoid confusion with Express.js middleware.

Changes:

  • Rename apps/site/middleware.ts to apps/site/proxy.ts
  • Add named export const proxy = createMiddleware({
  • Maintain full compatibility with next-intl internationalization
  • Update comments to reflect proxy terminology

This resolves the deprecation warning:
'The middleware file convention is deprecated. Please use proxy instead.'

Refs: https://nextjs.org/docs/messages/middleware-to-proxy

Description

Validation

Related Issues

Fixed #8418

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@Faizanahmedsy
Faizanahmedsy requested review from a team as code owners December 14, 2025 14:00
@vercel

vercel Bot commented Dec 14, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nodejs-org Ready Ready Preview Dec 31, 2025 2:49pm

@github-actions

Copy link
Copy Markdown
Contributor

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/nodejs-website

Please review the changes when you have a chance. Thank you! 🙏

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

export const proxy = createMiddleware({

You should just be able to do this, no?

@Faizanahmedsy

Copy link
Copy Markdown
Author
export const proxy = createMiddleware({

You should just be able to do this, no?

I have done as per documentation, but let me try if this similer approch works

…ility

Migrate from the deprecated middleware.ts file convention to the new
proxy.ts convention as required by Next.js 16.0.10.

The middleware file convention has been deprecated and renamed to 'proxy'
to better clarify its purpose as a network boundary in front of the app,
and to avoid confusion with Express.js middleware.

Changes:
- Rename apps/site/middleware.ts to apps/site/proxy.ts
- Add named export function 'proxy' instead of default export
- Add NextRequest type import for type safety
- Maintain full compatibility with next-intl internationalization
- Update comments to reflect proxy terminology

This resolves the deprecation warning:
'The middleware file convention is deprecated. Please use proxy instead.'

Refs: https://nextjs.org/docs/messages/middleware-to-proxy

@MattIPv4 MattIPv4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reference to this file in CODEOWNERS needs updating, please

@Faizanahmedsy

Copy link
Copy Markdown
Author

hi @avivkeller I amended the commit to incorporate this feedback. I've verified that both approaches work correctly, and all tests pass

Comment thread apps/site/proxy.ts Outdated
@Faizanahmedsy

Copy link
Copy Markdown
Author

The reference to this file in CODEOWNERS needs updating, please

okay checking that

@Faizanahmedsy

Copy link
Copy Markdown
Author

The reference to this file in CODEOWNERS needs updating, please

hi @MattIPv4 I have done that please check if I have done it correctly or not

- apps/site/middleware.ts @nodejs/web-infra
+ apps/site/proxy.ts @nodejs/web-infra

@avivkeller

Copy link
Copy Markdown
Member

The added comment is still not needed, you only removed half of it.

@Faizanahmedsy

Copy link
Copy Markdown
Author

The added comment is still not needed, you only removed half of it.

yeah sorry about that check now f4507a8

@ovflowd ovflowd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We aren't using the new middleware because it's not compatible with OpenNext. That was intentional. Blocking changes.

opennextjs/opennextjs-cloudflare#972

@avivkeller avivkeller left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like Matt and Claudio still have concerns blockers, but LGTM regarding my previous blockers

@ovflowd

ovflowd commented Dec 14, 2025 •

Copy link
Copy Markdown
Member

Looks like Matt and Claudio still have concerns, but LGTM with my blockers

Not concerns. This actually cannot be merged, otherwise it breaks Cloudflare builds.

@ovflowd

ovflowd commented Dec 14, 2025

Copy link
Copy Markdown
Member

To be clear not against the changes, just, they cannot be merged meantime.

@Faizanahmedsy

Faizanahmedsy commented Dec 15, 2025 •

Copy link
Copy Markdown
Author

To be clear not against the changes, just, they cannot be merged meantime.

Okay 👍, I will try to remind you once Open Next Supports it

@ovflowd

ovflowd commented Dec 15, 2025

Copy link
Copy Markdown
Member

Thank you! You can keep the PR open although I'd recommend converting it back to a draft state.

@avivkeller avivkeller left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The file content is wrong, actually, we should still be exporting default, per the next-i18n next-intl docs

@MattIPv4

Copy link
Copy Markdown
Member

🤔 Are we sure the next-i18n docs are correct there? Given the proxy is a Next.js feature, I'd be included to follow the Next.js docs, not third-party docs... (I suspect a default export is supported for backwards compat alongside the named export Next.js wants folks to use now).

@avivkeller

Copy link
Copy Markdown
Member

(I suspect a default export is supported for backwards compat alongside the named export Next.js wants folks to use now).

https://nextjs.org/docs/app/getting-started/proxy#example states "You can export your proxy function as either a default export or a named proxy export". IMO if the next-intl docs want the default, we should do it

@Faizanahmedsy

Copy link
Copy Markdown
Author

HI @MattIPv4 @avivkeller Can you please check now

@ovflowd

ovflowd commented Dec 31, 2025

Copy link
Copy Markdown
Member

I mean looks fine, but has opennext actually implemented support to proxy.ts yet?

Comment thread apps/site/proxy.ts
import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs';

export default createMiddleware({
export const proxy = createMiddleware({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export const proxy = createMiddleware({
export default createMiddleware({

Just leave as it was 😅

This branch was successfully deployed

1 active deployment
Preview — fda06adc Deployed Dec 31, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migrate from Middleware to Proxy

5 participants