Kirby()->user() returns null when Kirby is installed in a Sub Folder

Thank you for your fast reply!

Sadly, your suggested code does not work either - it still does not state that I am logged in. Maybe worth mentioning what I am doing: Via some JS I have added a button to the panel frontend to send a request to the route. Unfortunately, the login check still returns a json with the status of 401 with your suggested code (even though I am logged in):

This is the code now (cms/site/config.php):

return [
    ...
    'routes' => [
        [
          'pattern' => 'foo/bar',
          'action'  => function () {
              if ($user = kirby()->user()) {
                return [ 'status' => 200];
              }
              
              return [ 'status' => 401];
          }
        ]
    ]
]

If it matters: I only have one user (admin@example.com) and I just want to check if the user is currently logged in or not in the browser.

What I don’t get is, before moving everything to a Sub Folder this worked (as suggested here Check for logged-in user from within router plugin - #2 by texnixe):

if (($user = kirby()->user()) && $user->isLoggedIn()) {
  // do stuff
}