From 9a1f767c40b431427bb9df1a9a91dfd95954b1bf Mon Sep 17 00:00:00 2001 From: George Desipris Date: Tue, 24 Oct 2023 01:53:43 +0300 Subject: [PATCH] fix(nextjs): Stop ts errors for non-static nextjs typed routes in authMiddleware --- .changeset/curly-ties-mix.md | 5 +++++ packages/nextjs/src/server/authMiddleware.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/curly-ties-mix.md diff --git a/.changeset/curly-ties-mix.md b/.changeset/curly-ties-mix.md new file mode 100644 index 0000000000..e51e72cb46 --- /dev/null +++ b/.changeset/curly-ties-mix.md @@ -0,0 +1,5 @@ +--- +'@clerk/nextjs': patch +--- + +Fix an issue where only static routes would be allowed by `publicRoutes` prop from `authMiddleware`. diff --git a/packages/nextjs/src/server/authMiddleware.ts b/packages/nextjs/src/server/authMiddleware.ts index 77fee7de8f..f823fa45fa 100644 --- a/packages/nextjs/src/server/authMiddleware.ts +++ b/packages/nextjs/src/server/authMiddleware.ts @@ -39,7 +39,9 @@ type ExcludeRootPath = T extends '/' ? never : T; type RouteMatcherWithNextTypedRoutes = | WithPathPatternWildcard> | NextTypedRoute - | (string & object); + // This is necessary to allow all string, using something other than `{}` here WILL break types! + // eslint-disable-next-line @typescript-eslint/ban-types + | (string & {}); const INFINITE_REDIRECTION_LOOP_COOKIE = '__clerk_redirection_loop';