It's weird (and somewhat hard to believe) that depending on whether you set up your app to do A or B (short circuit or not) Prometheus will either succeed connecting or get a 404 whereas your browser always connects successfully.
It may have to do with proxied vs. direct access or your server actually running on different ports or exposing the metrics on different paths in the 2 setups (essentially a configuration issue), but I am at a loss as to how your browser succeeds when Prometheus fails. You can start debugging by running curl or wget from the server where Prometheus is running, maybe your workstation/laptop has access to your app whereas the server doesn't.