I find magnesium and potassium are the key for me. I supplement both of them and no longer have leg cramps. Adding some potassium rich foods might be sufficient for you. I hate taking potassium, but my muscles just seem to need it.
You could also try just drinking more water throughout the day instead of right before bed.