A rainbow is a meteorological phenomenon that is caused by reflection, refraction and dispersion of light in water droplets resulting in a spectrum of light appearing in the sky.
https://en.wikipedia.org/wiki/Sunset
As a ray of white sunlight travels through the atmosphere to an observer, some of the colors are scattered out of the beam by air molecules and airborne particles, changing the final color of the beam the viewer sees. Because the shorter wavelength components, such as blue and green, scatter more strongly, these colors are preferentially removed from the beam
Mainstream accepts that the Universe is full of "gas clouds". But these gas clouds have no influence on starlight or galaxy light.
Also see:
https://arxiv.org/ftp/arxiv/papers/0904/0904.3232.pdf
The main point that needs to be emphasized in the present discussion is that the well-known observation of star image displacements during solar eclipses does not constitute experimental proof that light follows a curved trajectory when passing by massive bodies.
https://arxiv.org/ftp/physics/papers/0409/0409124.pdf
In fact many of the general relativity tests are explained without general relativity on the basis of refraction phenomenon.
There is no refraction happening in the Universe. It happens only on Earth. Earth is a special place, where this amazing and unique phenomenon can be found. Also, it's probably the only place where there is no dark matter, the rest of the Universe is full of it.