From a015e1b898547d64a20426ae871f33f7d3c3b93a Mon Sep 17 00:00:00 2001 From: willx12123 Date: Sat, 1 Mar 2025 15:46:04 +0800 Subject: [PATCH] docs: Update Clerk example in middleware docs (#1754) 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 https://github.com/amannn/next-intl/issues/1458 --- docs/src/pages/docs/routing/middleware.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/pages/docs/routing/middleware.mdx b/docs/src/pages/docs/routing/middleware.mdx index 70ce7c58b..caffb9c98 100644 --- a/docs/src/pages/docs/routing/middleware.mdx +++ b/docs/src/pages/docs/routing/middleware.mdx @@ -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); }); @@ -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