Next.js Discord

Discord Forum

Exclude cron jobs from Clerk Auth?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
Anyone know how I can exclude the middleware from Clerk from running on my routes in folder: /api/cron?

Here's the current file:

import { authMiddleware } from "@clerk/nextjs";

// 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({
  debug: false,
});

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



I believe we need to update the matcher but not sure how to do it correctly.

0 Replies