Slim V3 - How to block display of credentials on a 404?

Any time I get a “Page Not Found” response from Slim (v3), it lists the Basic Auth credentials in the “Visit the Home Page” link at the bottom of the result. Ugh. That makes me itch.

How do I either block the link/credentials, or modify the 404/PNF output - without having to unset the notFoundHandler?



This forces me to unset the notFoundHandler - which now gives me random Slim not found errors that dont point to the calling source.


You may set a Custom Not Found handler.

For example:

$container['notFoundHandler'] = function ($c) {
    return function ($request, $response) use ($c) {
        return $response->withStatus(404)
            ->withHeader('Content-Type', 'text/html')
            ->write('Your Custom Page Not Found...');




I hope it help.

Thanks!! That definitely helps. Dont know how/why I missed that in the docs. SMH