HonoH
Honoβ€’2y ago
Huge Letters

How to resolve relative routes

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?
This router exists as a subrouter so it has no idea what route it has been assigned to.

The only solution I could come up with would involve doing a route :total-unique-param/* and then looking at the matched route and the request path and resolving them to a relative url.
image.png
Was this page helpful?