threads icon indicating copy to clipboard operation
threads copied to clipboard

Error: Clerk: auth() was called but it looks like you aren't using `authMiddleware` in your middleware file.

Open krutikbundela opened this issue 1 year ago • 13 comments

Unhandled Runtime Error 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

The middleware.ts is on same level as app image

not able to figureout what is the issue if someone can help tha would be really greatfull

krutikbundela avatar Sep 11 '23 12:09 krutikbundela

Did you find solution for this?

NammDev avatar Sep 19 '23 07:09 NammDev

Same problem here. Changed to node 20.1.0 and worked.

MichelHMachado avatar Sep 21 '23 17:09 MichelHMachado

Same problem here. Changed to node 20.1.0 and worked.

Yes, This worked, noticed you have to use the right npm package when working with clerk, some are not compatible with the latest version using version node 18.0.0 will initialize your nextjs but won't work with the api routing and authmiddleware, but when tested on new version (20.1.0) it worked.

  • nvm install 20.1.0

if you don't want to add it permanently to your bash after closing your terminal.

you can use it again with (nvm use 20.1.0) when working on a new terminal to prevent the authmiddleware error.

Toristeju112 avatar Oct 05 '23 09:10 Toristeju112

i installed (upgraded) node by downloading it from their site, then re ran my project, but it does'nt still work, can anyone provide a more detailed way to resolve this issue? thanks!

Adedayo-Onabamiro avatar Oct 05 '23 12:10 Adedayo-Onabamiro

i installed (upgraded) node by downloading it from their site, then re ran my project, but it does'nt still work, can anyone provide a more detailed way to resolve this issue? thanks!

make sure your middleware.ts is at the root directory, then if you are using clerk@latest install nvm i 20.1.0. confirm by checking the node -v , it must be node v - 20.1.0 . check middleware configuration and re run

Toristeju112 avatar Oct 05 '23 12:10 Toristeju112

honestly tried these and still isnt working, have you completed the project? so i could get like a starter file and all ill have to do is npm i

Adedayo-Onabamiro avatar Oct 05 '23 12:10 Adedayo-Onabamiro

honestly tried these and still isnt working, have you completed the project? so i could get like a starter file and all ill have to do is npm i

which project exactly? what's your node version, nextjs version and clerk version

Toristeju112 avatar Oct 05 '23 20:10 Toristeju112

the threads project. my node is 20.3.1, my next is 13.5.4 and my clerk is 4.25.2 i used npm and npx to check all these versions, although currently, i copied JSM's package.json, to try to fix my error and did all sorts and it didnt work.

Adedayo-Onabamiro avatar Oct 06 '23 11:10 Adedayo-Onabamiro

the threads project. my node is 20.3.1, my next is 13.5.4 and my clerk is 4.25.2 i used npm and npx to check all these versions, although currently, i copied JSM's package.json, to try to fix my error and did all sorts and it didnt work.

the threads project, okay use: Next: 13.4.19 Node: 20.1.0 clerk: 4.25.1

is a more stable version.

Toristeju112 avatar Oct 06 '23 13:10 Toristeju112

the threads project. my node is 20.3.1, my next is 13.5.4 and my clerk is 4.25.2 i used npm and npx to check all these versions, although currently, i copied JSM's package.json, to try to fix my error and did all sorts and it didnt work.

the threads project. my node is 20.3.1, my next is 13.5.4 and my clerk is 4.25.2 i used npm and npx to check all these versions, although currently, i copied JSM's package.json, to try to fix my error and did all sorts and it didnt work.

the threads project, okay use: Next: 13.4.19 Node: 20.1.0 clerk: 4.25.1

is a more stable version.

I am running this project as well and here is the versions I am using "@clerk/nextjs": "^4.25.3", "next": "13.5.4", Node: v20.8.0

I was getting the error trying several version combos on this one, my problem was I am using a source folder and had the middleware file in the root dir, once I moved it to the src folder everything worked as expected.

Digitl-Alchemyst avatar Oct 10 '23 22:10 Digitl-Alchemyst

I'm following Antonio's AI companion tutorial and this got me completely stuck.. Tried all the node versions, no idea what will solve this. Anyone had any luck on this particular project? middleware ts is on the same level as the app folder, node v is 20.1.0.. everything seems right.

image image

luketas avatar Oct 21 '23 19:10 luketas

I'm following Antonio's AI companion tutorial and this got me completely stuck.. Tried all the node versions, no idea what will solve this. Anyone had any luck on this particular project? middleware ts is on the same level as the app folder, node v is 20.1.0.. everything seems right.

image image

bro have u got the solution?

AniketBajaj2024 avatar Dec 29 '23 17:12 AniketBajaj2024

Im stuck on:

node: 20.11.0 clerk: 4.29.9 next: 14.1.3

This is really frustrating. As for now I just disabled authentication by removing the middleware part from /api/uploadthing/core.ts as onUploadComplete doesn't do much with user data anyway. Obviously this is not production ready since it doesn't authenticate the user when uploading stuff... but whatever, its just educational course 👍

This is what you get when you create tutorials with xxx@latests 😮‍💨 if it works at time when @adrianhajdin creates it, it might not work on latest packages 🤷

Stackustack avatar Mar 14 '24 14:03 Stackustack