Next.js Discord

Discord Forum

Dynamic route conflict with folder path in app directory

Unanswered
Chestnut-collared Longspur posted this in #help-forum
Open in Discord
Chestnut-collared LongspurOP
Hi,

I have a dynamic route /[shopname] and static route /admin at the root folder. Unfortunately when accessing /admin, it goes to /[shopname].

How do I fix this? Thanks!

12 Replies

Giant panda
This happens because the routes are at the same branch level of the tree. The dynamic route /[shopname] can accept anything as the route so when you visit /admin, it's considered to be a dynamic page in that dynamic route. You would need to move the dynamic route within a nested route. You could move it within something like shop/[shopname] and it should then work as intended.
Chestnut-collared LongspurOP
thanks @Giant panda unfortunately I guess there is no way to prioritize static routes first right?
Chestnut-collared LongspurOP
thanks very much!
@Chestnut-collared Longspur Hi, I have a dynamic route /[shopname] and static route /admin at the root folder. Unfortunately when accessing /admin, it goes to /[shopname]. How do I fix this? Thanks!
i can't reproduce it
@joulev this is just plain wrong. if the issue in question is not due to a misconfiguration by the OP, this is a nextjs bug
Giant panda
My mistake then. Does next prioritize static routes before trying to use a dynamic route?
yes
static routes are taken first before any dynamic route handling is done
Giant panda
My bad then. I had a similar issue as OP a while back and thought that wasn't the case. May have been some misconfiguration.
Chestnut-collared LongspurOP
Wait maybe I need to update nextjs
Chestnut-collared LongspurOP
thanks @Sloth bear @Giant panda 12.2.2 -> 13.0.2 solved this