This question already has an answer here:
I know that photons have no mass and that a photons exist only moving at the speed of light. So what is the cause that a massive astronomical object can bend a ray of light? I have two thoughts, but I am confused which of these, if any is correct:
A gravitational field of a massive astronomical object curves spacetime and affects the light traveling near this object indirectly. That is, for external viewers the light bends, but for the light itself it is still traveling in a straight line. So I mean, that the coordinates in that place are curved, but only for the external viewer.
Energy of a photon is equivalent to mass, so the gravity field interacts with photons directly the same way, as if they would have mass (equivalent to the energy).