Next.js Discord

Discord Forum

[Error: catch all segment must be the last segment] – setting up a catch all route with @modal.

Unanswered
Nebelung posted this in #help-forum
Open in Discord
NebelungOP
Hey, it's breaking my head but i'd expect this to be possible.

Error: [Error: Invalid segment Dynamic("slug"), catch all segment must be the last segment (segments: [Group("pages"), Group("public"), Static("browse"), OptionalCatchAll("slug")])

What I'm trying to achieve:
To have static route browse, when someone filters then they do it on dynamic route browse/filter, both routes have modal available. Is such set up possible? Thanks!

My project's folder structure:
app
├── (pages)
│   ├── (public)
│   │   ├── browse
│   │   │   ├── [[...slug]]
│   │   │   │   ├── @modal
│   │   │   │   │   ├── [slug]
│   │   │   │   │   │   ├── modal.tsx
│   │   │   │   │   │   └── page.tsx
│   │   │   │   │   └── page.tsx
│   │   │   │   ├── default.tsx
│   │   │   │   └── page.tsx

1 Reply

NebelungOP
Here is the sketch to better explain my desired structure.