Next.js Discord

Discord Forum

Dynamic routing catch root page

Answered
English Spot posted this in #help-forum
Open in Discord
English SpotOP
I have a /[username] layout somehow when i navigate to /, the page shows just fine but it triggers my [/username] layout API calls which would result an error and i would like to avoid that.
I would like to avoid this how do i do it. This is my folder structure looks like
Answered by Saint Hubert Jura Hound
So ur asking how to make the layout not run the api calls on /? Check if the username parameter exists or is not empty and run the calls based on that
View full answer

10 Replies

English SpotOP
This is when i navigate to '/'
The error is not supposed to be there bcos this it's [username] layout error
How to handle this.
Thanks in advance
@Giant panda can you share your tree structure of your pages inside app router
English SpotOP
Like this?
@English Spot This is when i navigate to '/' The error is not supposed to be there bcos this it's [username] layout error How to handle this. Thanks in advance
Saint Hubert Jura Hound
So ur asking how to make the layout not run the api calls on /? Check if the username parameter exists or is not empty and run the calls based on that
Answer
@Saint Hubert Jura Hound So ur asking how to make the layout not run the api calls on /? Check if the username parameter exists or is not empty and run the calls based on that
English SpotOP
So i have tried applying this, and for some reason it there's a paramater for my username even though it's empty
Is this normal? :o
Saint Hubert Jura Hound
How are u getting the params?
English SpotOP
Okay nvm, i think there's something wrong with my cached db
When i try it in incognito mode it doesnt show up
I just remembered this filename is from another project
:thinq: