Eat a nutrient dense diet with a variety of foods from different food groups (fruits, vegetables, whole grains, lean proteins) in order to prevent muscle loss. Be sure to get enough sleep! It is recommended that adults get at least 7 hours a day, but experts suggest getting more like 8-9 hours daily is more optimal. Lastly, prevent physical inactivity for a prolonged amount of time. Adding some brief activity breaks throughout a daily sitting routine is metabolically beneficial compared to not having breaks.
Blog: https://nutritionhealthworks.com/nutrition-blog/are-you-killing-your-metabolism/