Skip to content

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