Skip to content

Commit

Permalink
docs: Update Clerk example in middleware docs (#1754)
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

Fixes #1458
  • Loading branch information
willx12123 authored Mar 1, 2025
1 parent 6e3304c commit a015e1b
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 @@ -265,8 +265,8 @@ const handleI18nRouting = createMiddleware(routing);

const isProtectedRoute = createRouteMatcher(['/: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 All @@ -277,7 +277,7 @@ export const config = {
};
```

(based on `@clerk/nextjs@^5.0.0`)
(based on `@clerk/nextjs@^6.0.0`)

### Example: Integrating with Supabase Authentication

Expand Down

0 comments on commit a015e1b

Please sign in to comment.