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

**URL:** <https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626>\
**Category:** Next.js\
**Created:** [November 14, 2023, 3:35am UTC](https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626 "2023-11-14T03:35:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![horizonweb](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@horizonweb](https://forum.codewithmosh.com/u/horizonweb)\
**Post date:** [November 14, 2023, 3:35am UTC](https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626/1 "2023-11-14T03:35:35Z")

</div>

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:

```auto
> next-app@0.1.0 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!

---

<div class="post-metadata">

**Author:** ![Programmist](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/programmist/32/7006_2.png) [@Programmist](https://forum.codewithmosh.com/u/Programmist)\
**Post date:** [November 14, 2023, 6:06am UTC](https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626/2 "2023-11-14T06:06:04Z")

</div>

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:

```auto
app
├── [...nextauth]
│ └── route.ts
│ └── someDirectory

```

---

<div class="post-metadata">

**Author:** ![horizonweb](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@horizonweb](https://forum.codewithmosh.com/u/horizonweb)\
**Post date:** [November 14, 2023, 4:57pm UTC](https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626/3 "2023-11-14T16:57:06Z")

</div>

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

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Mdchristien](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/mdchristien/32/5930_2.png) [@Mdchristien](https://forum.codewithmosh.com/u/Mdchristien)\
**Post date:** [November 28, 2023, 4:37pm UTC](https://forum.codewithmosh.com/t/nextjs-error-catch-all-must-be-the-last-part-of-the-url/23626/4 "2023-11-28T16:37:02Z")

</div>

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