Before training, a meal containing carbohydrate and some protein one to three hours ahead suits most people. Afterwards, aim for protein and carbohydrate within a few hours. Total daily intake matters considerably more than the precise timing of either meal.
Carbohydrate is the main fuel for hard training, so the pre-session meal is mostly about topping up available energy and avoiding hunger or digestive discomfort. Something like oats and yoghurt, rice and chicken, or toast with eggs two hours out works well. Closer to the session, reduce fat and fibre and keep the portion smaller, since they slow digestion.
If you train first thing in the morning and eating is unappealing, a small carbohydrate source such as a banana or a drink containing some carbohydrate is usually enough. Training fasted is not harmful for most people, though many find their output drops on longer or harder sessions.
Recovery is driven by getting enough protein across the day and replacing the energy you used. A meal with roughly 25 to 40 g of protein plus carbohydrate within a few hours covers it. The old idea of a narrow 30-minute window has softened considerably; it matters most if you train twice in one day or trained fasted.
Keep pre-session food familiar. Competition day is not the time to try a new meal. If you regularly feel heavy or nauseous, move the meal earlier or make it smaller rather than eliminating it. If you fade badly in the last third of sessions, add carbohydrate before rather than during.
How the body actually supplies energy for different efforts is explained in Exercise Physiology and Energy Systems. For individual medical or dietary needs, including diabetes, pregnancy, or a history of disordered eating, speak with a qualified dietitian or your doctor rather than following general guidance.