Get current match url in action

I want current match url in action. See below
‘routes’ => [

    [

      'pattern' => '(:all)',

      'action'  => function () {


        // do something here

        // when the URL matches the pattern above

        $page = page->find('custom_url', 'I want to pass current match url here');
       return page('/products/fd');
      }

],

You can get matched path like that:

[
  'pattern' => '(:all)',
  'action'  => function($path) {
    // ...
  }
]

Doc: Routing | Kirby

Thanks…!
Is it possible to get page by field value in action block?

You can try:

[
  'pattern' => '(:all)',
  'action'  => function($path) {
    return site()->index()->findBy('custom_url', $path);
  }
]

Note that you should be careful with $site->index() (can affect performance in large sites), so if you can limit where Kirby should look for the requested page, then do.