Getting 404 when page is a draft

Hi,

i’am getting a 404, when a page is set as a draft and opened from the panel (so i’m logged in). If the page is set as listed or unlisted it will show up correctly.

Do you have any idea, why this happens and how to solve it?

Best regards

Matthias

Do you mean when you click on “Open” in the Panel? I have never experienced this myself. Which Kirby version are you using?

Yes - when I click “open” from the Panel I’m getting a 404. Kirby version is 3.5.3.1.

Could it be related to this route configuration I’m using for this website?

'routes' => [
        [
            'pattern' => '(:any)',
            'action'  => function($uid) {
                $page = page($uid);
                if(!$page) $page = page('lorem/' . $uid);
                if(!$page) $page = page('ipsum/' . $uid);
                if(!$page) $page = site()->errorPage();
                return site()->visit($page);
            }
        ]
    ]

Yes, because this route affects all first level pages and $page = page($uid); doesn’t find drafts. Try $kirby->page($uid) instead.

Thanks. Now it works as it should. I just had to use kirby() instead of $kirby

$page = kirby()->page($uid);