How to exclude specific routes from Clerk middleware?
Anyone know how I can exclude the middleware from Clerk from running on my routes in folder: /api/cron?
Here's the current file:
I believe we need to update the matcher but not sure how to do it correctly.
1 Reply
Since you are using the older, deprecated authMiddleware, you have two options:
1. Use
ignoredRoutes
to explicitly exclude that route.
2. Change the regex for matcher
to not match /api/cron
You can find more info here: https://clerk.com/docs/references/nextjs/auth-middleware
I suggest you ignore /api/cron
. Just know that this path will not be protected by Clerk. You'll have to handle authentication yourself.
Next.js: authMiddleware()
The
authMiddleware()
method allows you to protect your Next.js application using middleware.