Skip to content

Exclude manage from routing #437

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

Closed
wants to merge 4 commits into from
Closed

Conversation

georgealpha9
Copy link
Contributor

@georgealpha9 georgealpha9 commented May 8, 2025

Summary by CodeRabbit

  • New Features

    • Requests to /nl/manage are now permanently redirected to /manage.
  • Refactor

    • The /manage path and its subpaths are now excluded from internationalization processing.

Copy link

vercel bot commented May 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
signalen-frontend-wcag ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2025 1:37pm

Copy link

coderabbitai bot commented May 8, 2025

Walkthrough

The updates introduce a permanent redirect from /nl/manage to /manage in the Next.js configuration and modify the middleware's path matcher to exclude /manage and its subpaths from internationalization processing. No other configuration or logic changes were made.

Changes

File(s) Change Summary
next.config.js Added an asynchronous redirects function to define a permanent redirect from /nl/manage to /manage.
src/middleware.ts Updated the middleware matcher to exclude /manage and its subpaths from internationalization.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Next.js Server
    participant Middleware

    User->>Next.js Server: Request /nl/manage
    Next.js Server->>Next.js Server: Check redirects()
    Next.js Server-->>User: 301 Redirect to /manage

    User->>Next.js Server: Request /manage
    Next.js Server->>Middleware: Path matching
    Middleware-->>Next.js Server: Skip i18n processing (excluded path)
    Next.js Server-->>User: Serve /manage content
Loading

Poem

🐇
A hop from NL to manage, so neat,
With a redirect, the journey’s complete.
Middleware now skips, as told,
For manage paths, both new and old.
The bunny cheers with every fix—
Next.js magic, in just two clicks!

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2974a33 and 2e37987.

📒 Files selected for processing (1)
  • src/middleware.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: e2e
🔇 Additional comments (1)
src/middleware.ts (1)

14-14: LGTM: Excluding /manage path from i18n middleware

The update correctly adds manage to the list of path patterns excluded from internationalization processing. This change aligns with the PR objective to exclude the manage path from routing and works in conjunction with the redirect rule added in the Next.js configuration.

Just ensure that:

  1. Any existing links in your application pointing to localized versions of manage (e.g., /nl/manage) are updated
  2. Users are properly informed if they had bookmarked any localized manage URLs
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bbee9f and 7d581e5.

📒 Files selected for processing (1)
  • next.config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: e2e

Copy link

@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 (4)
middleware.js (4)

3-15: Consider handling path variants.

The middleware correctly blocks the exact paths '/manage' and '/nl/manage', but does not account for trailing slashes or other path variations. Users might still access these routes by adding a trailing slash (e.g., '/manage/').

Consider using a more flexible path matching approach:

- if (url.pathname === '/manage' || url.pathname === '/nl/manage') {
+ if (url.pathname === '/manage' || url.pathname === '/nl/manage' || 
+     url.pathname === '/manage/' || url.pathname === '/nl/manage/') {

Or even better, use a regex pattern:

- if (url.pathname === '/manage' || url.pathname === '/nl/manage') {
+ if (/^\/(?:nl\/)?manage\/?$/.test(url.pathname)) {
🧰 Tools
🪛 ESLint

[error] 8-11: Replace ⏎······{·message:·'Not·Found'·},⏎······{·status:·404·}⏎···· with {·message:·'Not·Found'·},·{·status:·404·}

(prettier/prettier)


8-11: Format JSON response per linting rules.

There's a formatting issue flagged by ESLint regarding the JSON response structure.

- return NextResponse.json(
-   { message: 'Not Found' },
-   { status: 404 }
- )
+ return NextResponse.json({ message: 'Not Found' }, { status: 404 })
🧰 Tools
🪛 ESLint

[error] 8-11: Replace ⏎······{·message:·'Not·Found'·},⏎······{·status:·404·}⏎···· with {·message:·'Not·Found'·},·{·status:·404·}

(prettier/prettier)


17-19: Config setup looks good, but add a newline.

The matcher configuration correctly targets the intended paths. There's a minor linting issue about adding a newline at the end of the file.

export const config = {
  matcher: ['/manage', '/nl/manage'], // Apply middleware to these paths
}
+
🧰 Tools
🪛 ESLint

[error] 19-19: Insert

(prettier/prettier)


7-12: Potential redundancy in path checking.

The middleware function checks for specific paths that are already specified in the matcher configuration. While this adds an extra layer of validation, it's worth noting that the matcher already ensures the middleware only runs on these paths.

If you prefer to keep the explicit check (which is fine for clarity), you might consider making the comment reflect this redundant validation:

- // Block /manage and /nl/manage by returning a 404 response
+ // Double-check paths and block /manage and /nl/manage by returning a 404 response
🧰 Tools
🪛 ESLint

[error] 8-11: Replace ⏎······{·message:·'Not·Found'·},⏎······{·status:·404·}⏎···· with {·message:·'Not·Found'·},·{·status:·404·}

(prettier/prettier)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d581e5 and fe75abb.

📒 Files selected for processing (1)
  • middleware.js (1 hunks)
🧰 Additional context used
🪛 ESLint
middleware.js

[error] 8-11: Replace ⏎······{·message:·'Not·Found'·},⏎······{·status:·404·}⏎···· with {·message:·'Not·Found'·},·{·status:·404·}

(prettier/prettier)


[error] 19-19: Insert

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: e2e
🔇 Additional comments (1)
middleware.js (1)

1-1: Good import choice.

Correctly importing NextResponse from 'next/server' which is the appropriate Next.js API for handling middleware responses.

Copy link

@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)
next.config.js (1)

6-14: Consider updating the comment to match the actual implementation

The comment on line 10 says "Redirect to a 404 page or any other page", but the actual destination is /manage. This is misleading since you're not redirecting to a 404 page but rather consolidating the paths. According to the summary, you're using middleware to intercept both the /manage and /nl/manage paths to return a 404 JSON response.

Consider updating the comment to better reflect what's happening, such as:

-        destination: '/manage', // Redirect to a 404 page or any other page
+        destination: '/manage', // Consolidate Dutch path to the main manage path (both handled by middleware)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe75abb and 2974a33.

📒 Files selected for processing (1)
  • next.config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: e2e
🔇 Additional comments (2)
next.config.js (2)

6-14: Verify middleware implementation for both paths

This redirect from /nl/manage to /manage works as intended only if your middleware is correctly intercepting both paths as mentioned in the summary. Make sure that the middleware handling is properly implemented to return 404 responses for both /manage and /nl/manage paths.

Since the redirect will send users from /nl/manage to /manage, you only need to ensure the middleware handles the /manage path properly, as users will never actually see the /nl/manage path.


6-14: LGTM: The previous infinite redirect loop is fixed

The current implementation correctly resolves the previous issue where /manage was redirecting to itself, creating an infinite loop. Now you're only redirecting /nl/manage to /manage, which works well with the middleware approach described in the summary.

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.

2 participants