When an electromagnetic wave travels through space, including a vacuum, it does not interact with any medium in the conventional sense. However, the expansion of the universe itself can cause a phenomenon called cosmological redshift, which leads to a loss of energy of the wave.
The cosmological redshift is a consequence of the expansion of space. As the universe expands, the wavelengths of the photons within the electromagnetic wave also stretch along with the expansion of space. This stretching of wavelengths causes the photons to become "stretched out," resulting in a decrease in their energy.
The redshift of light from distant astronomical objects, such as supernovae billions of light years away, is primarily due to the expansion of space between the source and the observer. As the light travels through this expanding space, the wavelengths of the photons gradually increase, causing a corresponding decrease in energy. This decrease in energy is observed as a redshift in the spectrum of the light.
It's important to note that this redshift does not involve an interaction with any specific particles or matter along the way. It occurs purely as a result of the expanding universe and the stretching of spacetime itself.