How do I use Path Matcher for front page?
Your code is assuming that the request URI for / will retrieve /node on the getAliasByPath() method call. It won't. Setting the Drupal front page isn't the same as setting a path alias in the Path module.

Use the following code, which will return Drupal's internal /node path even on / requests.

$current_path = \Drupal::service('path.current')-&gt;getPath();