chore: migrate from middleware.ts to proxy.ts for Next.js 16 compatib…#8419
chore: migrate from middleware.ts to proxy.ts for Next.js 16 compatib…#8419Faizanahmedsy wants to merge 6 commits intonodejs:mainfrom
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.
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.
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 |
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 |
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. |
|
🤔 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). |
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 |
|
HI @MattIPv4 @avivkeller Can you please check now |
|
I mean looks fine, but has opennext actually implemented support to proxy.ts yet? |
| import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs'; | ||
|
|
||
| export default createMiddleware({ | ||
| export const proxy = createMiddleware({ |
There was a problem hiding this comment.
| export const proxy = createMiddleware({ | |
| export default createMiddleware({ |
Just leave as it was 😅
…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.