Next.js Discord

Discord Forum

Clerk middleware error

Unanswered
arnez posted this in #help-forum
Open in Discord
Avatar
arnezOP
I don't really know what to do. I copy pasted middleware from clerk and my dashboard looks just fine

JS ⨯ node_modules\@clerk\nextjs\dist\esm\server\getAuth.js (28:12) @ eval
 ⨯ 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
    at DashboardLayout ([subjectId]/layout.tsx:18:75)
    at async Promise.all (index 0)
    at async Promise.all (index 0)
digest: "203805"
null

22 Replies

Avatar
Clown
middleware must be in the same folder as your package.json
Or inside src folder if you use that
Avatar
arnezOP
it is
Avatar
Clown
If this is your "middleware.ts":

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({});
 
export const config = {
      matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
};
 
Avatar
arnezOP
yes
Avatar
Clown
Try logging to the console with the middleware
To confirm it works
Check browser logs and console logs to see if there is anything
Avatar
arnezOP
nothing
i was reading about it
it may be clerk bug
bug that clerk's dev team made
Avatar
Clown
Welp, then you'll have to follow up there
Avatar
arnezOP
Image
Avatar
Clown
Try checking that link to modify that middleware and a console log in it to see if it even works
If it doesnt, then its better to follow up on clerk itself
If a new version dropped you will have to use
npm update
to make it update
Avatar
dumbboy
Just incase if you are able to find any solutions
@arnez can you try clearing cookies?
Avatar
arnezOP
sure i can try just give me a min
update does not work and i don't find cookies:)