-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
chore: migrate from middleware.ts to proxy.ts for Next.js 16 compatib… #8419
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe 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
left a comment
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.
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
62fb290 to
79378b7
Compare
MattIPv4
left a comment
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 reference to this file in CODEOWNERS needs updating, please
|
hi @avivkeller I amended the commit to incorporate this feedback. I've verified that both approaches work correctly, and all tests pass |
apps/site/proxy.ts
Outdated
| import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs'; | ||
|
|
||
| export default createMiddleware({ | ||
| // Migrated from middleware.ts to proxy.ts as per Next.js 16 deprecation |
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.
This comment is not needed
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.
This comment is not needed
removed in the next commit
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 entire comment is not needed
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 entire comment is not needed
I have removed the comments that i added, but kept the comments that where already there please check now f4507a8
okay checking that |
hi @MattIPv4 I have done that please check if I have done it correctly or not |
|
The added comment is still not needed, you only removed half of it. |
yeah sorry about that check now f4507a8 |
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.
We aren't using the new middleware because it's not compatible with OpenNext. That was intentional. Blocking 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.
Looks like Matt and Claudio still have concerns blockers, but LGTM regarding my previous blockers
Not concerns. This actually cannot be merged, otherwise it breaks Cloudflare builds. |
|
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 |
|
Thank you! You can keep the PR open although I'd recommend converting it back to a draft state. |
…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:
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
pnpm formatto ensure the code follows the style guide.pnpm testto check if all tests are passing.pnpm buildto check if the website builds without errors.