Skip to content

feat: enhance middleware to handle public and admin routes #44

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rohitdhakane6
Copy link
Contributor

This PR implements role-based access control (RBAC) using Clerk's middleware for route protection in the Next.js app. Public routes are accessible to all users, while admin routes and other protected routes require authentication.

Changes:

  • Added clerkMiddleware to manage authentication and role-based access.
  • Protected all routes except public ones (/ and /pricing), ensuring users must be authenticated to access them.
  • Restricted /admin routes to users with the role of "admin."
  • Configured route matching for Next.js internals and static files to ensure proper routing behavior.

Protection Rules:

  • Public Routes: "/", "/pricing(.*)" (accessible without authentication).
  • Protected Routes: All other routes are protected and require user authentication.
  • Admin Routes: Only accessible to users with the "admin" role.

For more details on Clerk's RBAC implementation, refer to [Clerk RBAC Documentation](https://clerk.com/docs/references/nextjs/basic-rbac).

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