Problem with cookbook recipe „Access forbidden“: No Logout possible

Newbie here. I want to make a part of a site accessible only for a certain user group without panel access. I followed the recipe and on my Localhost (Mamp) everything works fine.

When I move the files to the remote server everything works except the logout function. The user is not logged out and not redirected to the login page. The error page of my theme (Zero One) is shown instead. Both hosts run on PHP 8.2. Running out of ideas …

Do you have multiple config files per environment in that theme maybe and the route is only in one of them?

Thanks a lot for the quick reply but that did not help. I have only one config-file that contains the route but the logout link still has the same behavior and throws an error.

Please post the config file

<?php

return [

  'routes' => [
    [
      'pattern' => 'logout',
      'action'  => function() {

        if ($user = kirby()->user()) {
          $user->logout();
        }

        go('login');

      }
    ]
],

    // https://getkirby.com/docs/reference/system/options/languages
    'languages' => true,
    // 'languages.detect' => false,

    // https://getkirby.com/docs/reference/system/options/smartypants
    'smartypants' => true,

    // Robots plugin https://github.com/bnomei/kirby3-robots-txt
    'bnomei.robots-txt.sitemap' => 'sitemap.xml',
    'bnomei.robots-txt.groups' => [ // array or callback
      '*' => [ // user-agent
          'disallow' => [
              '/kirby/',
              '/site/',
          ],
          'allow' => [
              '/media/',
          ]
      ]
    ],

    // Write custom CSS to file
    'hooks' => [
      'site.update:after' => function($newSite) {
    
        $css = $newSite->customCss()->value();
          if (kirby()->languages()->isNotEmpty()) {
            if (kirby()->language()->isDefault()) {
              F::write(kirby()->root('assets') . '/css/site.css', $css);
            }
          } else {
            F::write(kirby()->root('assets') . '/css/site.css', $css);
          }
        }
    ],

    // Support for language detect option https://getkirby.com/docs/guide/languages/introduction#automatic-language-detection
    'routes' => [
      [
          'pattern' => '/',
          'action'  => function () {
              $session = kirby()->session();

              if ($session->get('languages.detect', false) === false && option('languages.detect') === true) {
                  $session->set('languages.detect', true);

                  return kirby()
                      ->response()
                      ->redirect(kirby()->detectedLanguage()->url());
              }

              return page();
          }
        ]
    ],

    // Remove update notification for some plugins
    'updates.plugins' => [
      'avoskitchen/sanitizer'         => false,
      'bvdputte/kirby-bettersearch'   => false,
      'hananils/kirby-colors'         => false,
      'kirbyzone/sitemapper'          => false,
      'sylvainjule/code-editor'       => false,
      'microman/formblock'            => false,
      'zero/zero-one'                 => false,
      'getkirby/resave'               => false
    ]



];

Did not find a better way to post the file.

As I suspected, you overwrite the routes key later in the file, i.e. you have the routes key right at the top of the file, and then later again a routes key after the hooks, but each key can only exist once. So move the logout route inside the other routes.

BTW, when posting code, use three backticks before and after the code block, like in this screenshot:

three-backticks-800x

Thank you so much, that did the trick! I will try to learn a little bit more
syntax …