Ability to drop traffic when no route found

I see in code that when the router is not able to match, it always returns with a 404 error and the standard “no Route matched with those values” message. I am looking for a way to just drop traffic when no routes are found so that bots and others can’t scan for working endpoints.

I was hoping there is a way without customising code.