Next.js Discord

Discord Forum

How to add subroute in a catch-all route

Unanswered
Ankit posted this in #help-forum
Open in Discord
Avatar
AnkitOP
Examples:
cohorts/:cohortId/:termId/:subjectId/:chapterId/session
cohorts/:cohortId/:subjectId/session
cohorts/:cohortId/:sessionId

cohorts/:cohortId/:termId/:subjectId/:chapterId/assignment
cohorts/:cohortId/:subjectId/assignment
cohorts/:cohortId/assignment


as you can see each hierarchy example will have a starting route as /cohorts and ends with either /session or /assignment
:cohortId, :termId, :subjectId, :chapterId come based on users selection, so i have turned that into a [...slug] (catch-all) route but now when i create a session and assignment route i get the follwing error Catch-all must be the last part of the URL.


so how can i achieve route like cohorts/[...slug]/[session|assignment]
where slug might hold cohortId, termId, subjectId or chatperId and will end with either session or assignment route

0 Replies