Next.js Discord

Discord Forum

Why my [...slug].tsx has priority over index.tsx?

Unanswered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
I have this weird usecase when NextJS doesn't serve properly static index.tsx but prefer dynamic [...slug].tsx which are located in the same folder shop.
When building website in production mode I see that static index.tsx is built correctly but for some reason when requesting /shop url it actually reads [...slug].tsx and not index.tsx.
If I remove [...slug].tsx then index.tsx works fine, so this way I understand that there is no errors in index.tsx itself. But there is some behavior which I can't see in documentation.
Any ideas how to fix that and set index.tsx priority over [...slug].tsx?

3 Replies

Chinese Alligator
you can change the [...slug].tsx to [slug].tsx
Satin AngoraOP
so the priority is
1. [...slug].tsx
2. index.tsx
3. [slug].tsx?
I need to keep [...slug].tsx since it should handle all the routes that starts with /shop but not root /shop itself