Zinc for a more useful answer
Are you hydrated? Do you have enough salts in your system, what is in your water?
In general I take 2-3l of water for anything more than an hour, more if it’s hot. I will add Torq in summer as I will sweat a lot.
Zinc was suggested as something to supplement with either as a powder to mix with water or in table form. For really big races before and after or as an emergency during ride.
If it’s not going into full blown cramp then maybe some more stretching will help.
Of course the 2 Olympians that have posted above probably know more than me….