Next's routing is inconsistently case sensitive #48043
Unanswered
christianjuth
asked this question in
Help
Replies: 3 comments
-
yeah, I noticed the same, using caps in slug should be managed |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hmm... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for this update! Will be super cautious when dealing with it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The issue
Next's routing system seems to case sensitive very inconsistently.
This is one of those things that seems like it should be a huge problem, and I'm not really sure why not many others are talking about it.
From my testing:
/one/Two
is NOT the same as/one/two
/One/two
IS the same as/one/two
/one/Two
=>/one/two/
crashes Next.js leading me to believe create an infinite loopPossible Solutions (hacks)
Solution 1 - Middleware
This works, but it's very crude. It downcases everything in the pathname without really understanding what it's chaning. For example, if I had
/blog/[slug]
I think it would make more sense for blog to be case insensitive, but let the page decide how to handle the paramslug
. However, using this middleware solutionslug
can only be lowercaseSolution 2 - Rewrites
This seems to work durning production, but crashes durning development. I could put in a flag so this redirect is only enabled in a build, but this already seems messy.
Fixing the underlying problem
I think it would be much better if Next added a config option that was something like
next.caseSensitiveRoutes = boolean
or something along those lines. Having it be an option would also prevent patching this from being a breaking change.Has anyone else run into this problem, and am I missing something obvious?
See related #21498
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions