Skip to content

Conversation

@adityai0
Copy link

@adityai0 adityai0 commented Nov 27, 2025

Closes #207

📝 Description

This PR migrates from the deprecated middleware file convention to the new proxy convention, following the updated Next.js v16 routing standards.
Learn more: https://nextjs.org/docs/messages/middleware-to-proxy

🔧 Changes Made

  • Replaced deprecated middleware.ts with the new proxy.ts file.
  • Updated routing logic to match the Next.js Proxy API.
  • Ensured compatibility with the latest Next.js version.
  • Adjusted import paths and configurations where necessary.

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Refactor
    • Internal function naming optimization with no impact to user-facing functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

The exported handler function in frontend/proxy.ts is renamed from middleware to proxy to align with Next.js's updated API convention. The function signature and implementation remain unchanged.

Changes

Cohort / File(s) Summary
Function Rename
frontend/proxy.ts
Renamed exported handler function from middleware to proxy to comply with Next.js API updates

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Verify the export name matches the new proxy convention across the file
  • Confirm no internal or external imports are still referencing the old middleware export name

Poem

🐰 A hop, a skip, a simple name,
From middleware to proxy—no shame!
Next.js demands our API dance,
We rename with care, not by chance.
Deprecation warnings? Consider them gone! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: migrating from deprecated middleware to proxy following Next.js guidelines, which matches the primary objective of this PR.
Linked Issues check ✅ Passed The code change directly addresses the primary objective in #207 by renaming the exported function from middleware to proxy to align with Next.js v16 standards.
Out of Scope Changes check ✅ Passed The change is narrowly focused on renaming the exported function and does not include unrelated modifications beyond the stated objective.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adityai0
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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/proxy.ts (1)

8-19: Remove unused route definitions or implement routing logic.

The publicRoutes, isPublicRoute, and isProtectedRoute variables are defined but never used. The function unconditionally returns NextResponse.next(), making these definitions dead code.

If the AuthGuard component handles all authentication (as the comment suggests), remove these unused definitions to keep the code clean. Otherwise, implement the routing logic that uses these checks.

Option 1 (if routing logic not needed): Remove dead code

 export async function proxy(req: NextRequest) {
-  // Get the pathname
-  const path = req.nextUrl.pathname;
-
-  // Define public routes that don't require authentication
-  const publicRoutes = ["/login", "/signup", "/"];
-  const isPublicRoute = publicRoutes.includes(path);
-
-  // Protected routes that require authentication
-  const isProtectedRoute =
-    path.startsWith("/creator") || path.startsWith("/brand");
-
-  // For protected routes, the AuthGuard component will handle the authentication check
-  // This middleware is just for basic routing logic
-
   return NextResponse.next();
 }

Option 2 (if routing logic needed): Implement the checks

For example, to redirect unauthenticated users from protected routes:

 export async function proxy(req: NextRequest) {
   // Get the pathname
   const path = req.nextUrl.pathname;
 
   // Define public routes that don't require authentication
   const publicRoutes = ["/login", "/signup", "/"];
   const isPublicRoute = publicRoutes.includes(path);
 
   // Protected routes that require authentication
   const isProtectedRoute =
     path.startsWith("/creator") || path.startsWith("/brand");
 
-  // For protected routes, the AuthGuard component will handle the authentication check
-  // This middleware is just for basic routing logic
-
+  // Redirect to login if accessing protected route without auth token
+  if (isProtectedRoute && !req.cookies.get("auth-token")) {
+    return NextResponse.redirect(new URL("/login", req.url));
+  }
+
   return NextResponse.next();
 }

Note: Per Next.js v16 guidelines, proxy should be used for lightweight redirects and not as a full session management or authorization solution.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 830fd62 and 4aae368.

📒 Files selected for processing (1)
  • frontend/proxy.ts (1 hunks)
🔇 Additional comments (2)
frontend/proxy.ts (2)

4-4: LGTM! Function rename aligns with Next.js v16 requirements.

The migration correctly renames the exported function from middleware to proxy as required by Next.js v16.


1-2: I'm unable to complete the verification because the repository cannot be accessed in the sandbox environment. Both direct repository cloning and GitHub CLI queries are failing due to access restrictions.

However, based on the review comment provided, here is my analysis:

Rewritten Review Comment:

Verify no remaining references to deprecated middleware.ts before considering migration complete.

The imports shown (lines 1-2) are correct for the new proxy.ts pattern using Next.js v16 conventions. However, before this PR can be merged, manually verify that no other files in the codebase still:

  • Import from the old middleware.ts file
  • Reference the deprecated middleware function
  • Contain stale middleware.ts paths in import statements

This verification is critical to ensure a complete migration from the old middleware pattern to the new proxy pattern.

@adityai0
Copy link
Author

@Saahi30 please review this and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant