District heating systems become more distributed with the integration of prosumers, including excess heat producers and active consumers. This calls for suitable heat market mechanisms that optimally integrate these actors, while minimizing and allocating operational costs. We argue for the inclusion of network constraints to ensure network feasibility and incentivize loss reductions. We propose a network-aware heat market as a Quadratic Program (QP), which determines the optimal dispatch and a set of nodal marginal prices. While heat network dynamics are generally represented by non-convex constraints, we convexify this formulation by fixing temperature variables and neglecting pumping power. The resulting variable flow heating network model leaves the sign and size of the nodal heat injections flexible, which is important for the integration of prosumers. The market is based on peer-to-peer trades to which we add explicit loss terms. This allows us to trace network losses back to the producer and consumer of these losses. Through a dual analysis we reveal loss components of nodal prices, as well as relations between nodal prices and between seller and buyer prices. A case study illustrates the advantages of the network-aware market by comparison to our proposed loss-agnostic benchmark. We show that the network-aware market mechanism effectively promotes local heat consumption and thereby reduces losses and total cost. We conclude that the proposed loss-aware market mechanism can help reduce operating costs in district heating networks while integrating prosumers.