Surely you know someone who would have advised someone about what to eat or not, to prevent headaches. And is that some foods may have a link to headaches. In general, experts agree on which components are not recommended: nitrates (hot dogs, sausages, etc), monosodium glutamate (used in some preparations of oriental food , especially low-quality Chinese), beverages with caffeine (coffee or colas), foods with tyramine ( chocolate , cheese, nuts) and alcoholic beverages.
And also … Note that, hunger can cause headaches, so eat normally and respect the regular schedule of meals that you have.
At the other hand … There are a number substances which may be beneficial and act as stabilizers headache factor. So B Vitamin, for example, strengthens the nervous system and it may be useful in headaches and in its forecast. Some plants, their infusions: lemon balm, passionflower, boldo, fumaria, ginko and mallow are some of them.