Static Paths case sensitivity
Answered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
I am using the pages router. i am generating paths, the path file is
For example if i go to the path
But if i do
Do i need to have middleware setup to handle this? I'd expect it to handle this automatically? idk
[name].tsxFor example if i go to the path
/Bob it works fineBut if i do
/bob its 404.Do i need to have middleware setup to handle this? I'd expect it to handle this automatically? idk
Answered by joulev
Nextjs paths are case sensitive as you’ve seen. Yes you can use middleware for this. In getStaticPaths generate the lowercase version of the paths, then in middleware you rewrite a request to its lowercase version
3 Replies
Orinoco CrocodileOP
anyone have any advice?
@Orinoco Crocodile I am using the pages router. i am generating paths, the path file is `[name].tsx`
For example if i go to the path `/Bob` it works fine
But if i do `/bob` its 404.
Do i need to have middleware setup to handle this? I'd expect it to handle this automatically? idk
Nextjs paths are case sensitive as you’ve seen. Yes you can use middleware for this. In getStaticPaths generate the lowercase version of the paths, then in middleware you rewrite a request to its lowercase version
Answer
Orinoco CrocodileOP
got it. thanks