According to general relativity, objects by the virtue of their mass have the ability to disrupt spacetime around them. This disruption in spacetime is actually what we call gravity.
So light always travels in a straight path in spacetime but because spacetime is now bent, the path appears to be curved in space