Dynamic routing with prefix
See original GitHub issueFeature request
we have a problem where we want to keep almost everything at the top level while support different dynamic routes with constant prefixes as differentiator. For example we have one route example.com/@username
where @
is a constant prefix and also another route example.com/[123_post_id] where the prefix is
123_... but
[@username].tsxis not different from
[123_post_id].tsx`
I understand we can put them into different folders and manage but the above is just an example and our application behaviour is based on prefixes
and everything being at the top level
Describe the solution you’d like
Ideally ability to add some sort of prefix to dynamic routing file names. i.e. [@:username]
where @
is a prefix and username
is the parameter … another design solution might be [<@>username]
or [username<@>]
where @
is a required fixed constant but can be placed anywhere [far more complex in implementation than prefixes]
Describe alternatives you’ve considered
- For now the native solution of
/profile/[username]/...
seems like the only option - Introducing a route manager to handle this situation
- reverse proxy
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
This issue / feature request needs to be reopened. It was prematurely closed without addressing the actual request.
“rewrite” function DOES NOT work to address the request. Please read more carefully before jumping into conclusion.
rewrite rule barely works with code below:
example.com/@username
The following case doesn’t work:
example.com/@username/about
<- 404 not found but this works:example.com/u/:username/about
*** If the above case “should work” but it’s not, then that’s a bug that needs to be addressed
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.