-
-
Notifications
You must be signed in to change notification settings - Fork 327
Migrate to Next.js 16 #2825
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
Migrate to Next.js 16 #2825
Conversation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughBumps Next.js and related packages to ^16.0.7, adds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3132b35 to
aa79c06
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/proxy.ts (1)
6-14: Consider adding error handling and preserving the original URL.The authentication logic is straightforward and follows Next.js 16 proxy conventions. However, consider these improvements:
- Error handling: If
getTokenthrows an error, the request will fail ungracefully. Add a try-catch block to handle potential errors.- Preserve original URL: Currently, users are redirected to
/auth/loginwithout preserving their intended destination. Consider adding the original URL as a query parameter for post-login redirect.Apply this diff to add error handling and URL preservation:
export default async function proxy(request: NextRequest) { - const token = await getToken({ req: request }) + try { + const token = await getToken({ req: request }) - if (!token) { - return NextResponse.redirect(new URL('/auth/login', request.url)) - } + if (!token) { + const loginUrl = new URL('/auth/login', request.url) + loginUrl.searchParams.set('callbackUrl', request.url) + return NextResponse.redirect(loginUrl) + } - return NextResponse.next() + return NextResponse.next() + } catch (error) { + console.error('Proxy authentication error:', error) + return NextResponse.redirect(new URL('/auth/login', request.url)) + } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/proxy.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2178
File: frontend/src/app/snapshots/[id]/page.tsx:0-0
Timestamp: 2025-09-21T17:04:48.154Z
Learning: User rudransh-shrivastava confirmed that suggested type safety improvements during Apollo Client migration were no longer relevant, reinforcing their preference to keep migration PRs focused on core migration changes rather than additional improvements.
🔇 Additional comments (2)
frontend/src/proxy.ts (2)
16-19: Matcher configuration is correct.The matcher pattern
'/my/mentorship/:path*'correctly protects all routes under/my/mentorship/. This follows Next.js conventions for path matching.
2-4: Move JWT validation from proxy.ts to a Node.js runtime endpoint or use an Edge-compatible JWT library.
getTokenfrom next-auth/jwt requires Node.js runtime and uses Node.js crypto modules, but proxy.ts runs on the Edge runtime by default in Next.js 16. This will cause runtime errors. Either move the token validation to an API route or Server Action (which run on Node.js), or use an Edge-compatible JWT library likejosewith Web Crypto for verification in proxy.ts. Alternatively, use next-auth'swithAuthmiddleware helper if performing simple presence checks.⛔ Skipped due to learnings
Learnt from: Rajgupta36 Repo: OWASP/Nest PR: 1717 File: frontend/src/app/api/auth/[...nextauth]/route.ts:13-25 Timestamp: 2025-08-10T11:08:47.258Z Learning: In the OWASP Nest codebase (frontend/src/app/api/auth/[...nextauth]/route.ts), input validation and string trimming for authentication-related queries like `isProjectLeader` and `isMentor` are handled in the backend rather than the frontend. The backend is responsible for sanitizing and validating input parameters.
e05af73 to
76ea291
Compare
90e145f to
aa79c06
Compare
frontend/src/proxy.ts
Outdated
| @@ -1,13 +1,13 @@ | |||
| // proxy.ts | |||
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.
Why did we add this?
|
arkid15r
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.
Thank you @mrkeshav-05



Proposed change
Migrated the project to Next.js 16.0.7.
Fixed: #2798
Changes Made:
package.json)next: ^15.5.7 → ^16.0.7
@next/eslint-plugin-next: ^15.5.7 → ^16.0.7
@next/third-parties: ^15.5.7 → ^16.0.7
eslint-config-next: ^15.5.7 → ^16.0.7
As middleware.ts is deprecated
Created
proxy.tsvia blogRemoved deprecated
middleware.tsAdded tests
proxy.test.tsChecklist
make check-testlocally; all checks and tests passed.