Wouldn’t this do basically nothing to prevent a 3rd party client from browsing your instance without authentication? I don’t know that there’s much that can really be done about this because you need open APIs for other instances to be able to access the content of your instance in order to make federation possible. That said, it’s an important consideration that anybody running a single person instance should consider. If you run a single person instance, people can learn a lot about you just by seeing which communities are available on your instance. The only way to obfuscate your actual interests is to have a dummy account subscribe to all the top communities on the biggest instances. (Which, honestly, this isn’t a bad strategy to employ anyway if you’re wanting a fresh All feed).
You can run headless or do what the person I was responding to recommended and put it behind an authenticated portal, but that’s not really going to stop other instances and clients from accessing the same resources that op is hoping to limit access to except in the most basic case of people casually browsing op’s Lemmy instance through op’s own lemmy-ui.
Edit, but to be clear, what I was responding to and my response didn’t directly address op’s specific concern (which I kind of misunderstood myself before just now rereading) that outside/guest users shouldn’t be able to search for communities from other instances and I think it’s a fair concern because just searching for a community from another instance brings in posts and could be a vector for spam/abuse.