Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
6 replies
JEM

Anyone else getting this error? Clerk: auth() ... looks like you aren't using `authMiddleware`

Error: Clerk: auth() was called but it looks like you aren't using authMiddleware in your middleware file. Please use authMiddleware and make sure your middleware matcher is configured correctly and it matches this route or page. See https://clerk.com/docs/quickstarts/get-started-with-nextjs

import { authMiddleware } from '@clerk/nextjs/server';

// This example protects all routes including api/trpc routes
// Please edit this to allow other routes to be public as needed.
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your middleware
export default authMiddleware({
  publicRoutes: ['/'],
});

export const config = {
  matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
};


nothing too crazy in my middleware, I did add the /server in the import cause I was testing some other solutions ... however clerk and next docs do not explicitly use /server in their middleware.ts
Learn how to use Clerk to quickly and easily add secure authentication and user management to your Next.js application. Clerk works seamlessly on both client side and server side components.
Use Clerk with Next.js | Clerk
Was this page helpful?