NextJS Error: Catch-all must be the last part of the URL

I’m working through the NextJS course and am at:

“Authentication with Next Auth”
9 - “Database Adapters”

When getting to the point where I had to restart the dev server, I am now receiving the error:

> [email protected] dev
> next dev

   ▲ Next.js 14.0.2
   - Local:        http://localhost:3000
   - Environments: .env

Error: Catch-all must be the last part of the URL.
    at UrlNode._insert (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:60:19)
    at UrlNode._insert (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:142:40)
    at UrlNode._insert (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:142:40)
    at UrlNode._insert (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:142:40)
    at UrlNode.insert (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:13:14)
    at /home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:165:46
    at Array.forEach (<anonymous>)
    at getSortedRoutes (/home/allan/Dev/Learning/next-app/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js:165:21)
    at Watchpack.<anonymous> (/home/allan/Dev/Learning/next-app/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js:1542:65)

I’m trying to retrace my steps but I’m not sure where I’m going wrong. If anyone could point me in the right direction to troubleshoot it would be greatly appreciated!

This error can be caused by having any route subdirectories within a catch-all route. Do you have any directories within [...nextauth]?

For instance, someDirectory in the example below would cause this error:

app
├── [...nextauth]
│   └── route.ts
│   └── someDirectory
1 Like

ahh that was it! I added the token folder when following along and didn’t remove it.

Thank you so much!

1 Like

I keep getting the notfound page each time i access: http://localhost:3000/api/auth/signin after doing all the necessary configuration