We study the transport of chiral Majorana edge modes (CMEMs) in a hybrid quantum anomalous Hall insulator-topological superconductor (QAHI-TSC) system in which the TSC region contains a Josephson junction and a cavity. The Josephson junction undergoes a topological transition when the magnetic flux through the cavity passes through half-integer multiples of magnetic flux quantum. For the trivial phase, the CMEMs transmit along the QAHI-TSC interface as without magnetic flux. However, for the nontrivial phase, a zero-energy Majorana state appears in the cavity, leading that a CMEM can resonantly tunnel through the Majorana state to a different CMEM. These findings may provide a feasible scheme to control the transport of CMEMs by using the magnetic flux and the transport pattern can be customized by setting the size of the TSC.