How to resolve relative routes #3021
-
I have a sub-router like this .get(
'/',
basicAuth({
username: 'user',
password: 'lol',
}),
async (c) => {
return c.render(<Dashboard />);
},
)
.get('*', (c) => {
return c.render(
<div>
not found. <a href={url}>go to homepage</a>
</div>,
);
}); How can I construct a URL to pass it to the anchor in the catch-all route so that it would point to the index route above? The only solution I could come up with would involve doing a route |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The problem would be extremely easy to solve if I could either
cause I then I could just scrub off the url tail with parameter value |
Beta Was this translation helpful? Give feedback.
-
Yeah ok, I think I've figured it out .get(':p{.*}', (c) => {
const url = c.req.path.replace(c.req.param('p') ?? '', '');
return c.render(
<div>
not found. <a href={url}>go to homepage</a>
</div>,
);
}) |
Beta Was this translation helpful? Give feedback.
Yeah ok, I think I've figured it out