hono: Weird 500 error during routing

What version of Hono are you using?

3.7.2

What runtime/platform is your app running on?

Node

What steps can reproduce the bug?

import { Hono } from 'hono';
import {serve} from "@hono/node-server";

const app = new Hono();

app.get('/:url{.*}', async (ctx) => {

    // I want receive ctx.req.param('url');

    return ctx.html("ok");
});

serve(app);

What is the expected behavior?

I want receive ctx.req.param('url') without problems for any requested path.

What do you see instead?

Absolutely empty 500 error

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@rajput-hemant @NicoPlyley

Thanx!

You’re welcome!

@vanodevium,

We can always use null assertion for the default value

For example:

const url = ctx.req.param('url') ?? 'default';

This way, if ctx.req.param('url') returns undefined, it will use 'default' as the default value.