Skip to content

Commit

Permalink
fix: correct integrating with clerk
Browse files Browse the repository at this point in the history
1. change `protect` usage to latest version
2. add locale prefix matcher and non locale prefix matcher at the same time to avoid infinite redirect
  • Loading branch information
willx12123 committed Feb 28, 2025
1 parent 6e3304c commit 9033787
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/src/pages/docs/routing/middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ import {routing} from './i18n/routing';

const handleI18nRouting = createMiddleware(routing);

const isProtectedRoute = createRouteMatcher(['/:locale/dashboard(.*)']);
const isProtectedRoute = createRouteMatcher(['/dashboard(.*)', '/:locale/dashboard(.*)']);

export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
export default clerkMiddleware(async (auth, req) => {
if (isProtectedRoute(req)) await auth.protect();

return handleI18nRouting(req);
});
Expand Down

0 comments on commit 9033787

Please sign in to comment.