having issues getting app.get('/@:username') working #3050
-
i am trying to get paths like /@russell to work in my hono app. I have tried everything I can think of.
and tried
i come from expressJS background and in there we can do it by using
which then allows us to use it in a GET |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I have a solution, but it's not the way it should be
it does work, can anyone think of a better solution please. However then we have another issue it doesn't work when we want to use route
the only way I can get it to work is do this (which I don't want to do)
and then in userRoute
It does work but then the url is http://example.com/@/russell/status/67816872 but I want it http://example.com/@russell/status/67816872 |
Beta Was this translation helpful? Give feedback.
-
Hi @redimongo, Another way to achieve this would be using Regex. If you write the route as follows: app.get('/:user{@[a-zA-Z0-9]+}', (c) => {
const user = c.req.param('user')
return c.text(user)
}) If you went to Also, if you want to allow everything to work, you can do |
Beta Was this translation helpful? Give feedback.
Hi @redimongo,
Another way to achieve this would be using Regex. If you write the route as follows:
If you went to
/test123
, the route would give a 404 error, but if you go to@test123
, it will return the userAlso, if you want to allow everything to work, you can do
/:user{@.+}
instead