Prevent it: train your gut and fuel to a number
Your gut is trainable, so train it. Practice your exact race fueling on your long runs and your back-to-backs, and build up slowly from whatever you actually take now (often only 40 to 60 grams of carbohydrate per hour) toward a target of roughly 60 to 90 grams per hour, using a glucose-plus-fructose mix so you can absorb more than a single sugar lets you. Most runners also need around 300 to 600 milligrams of sodium per hour, more if you are a heavy or salty sweater or you are racing in the heat, with fluid taken to thirst.
Drink first. Under-drinking drops your blood volume and your gut blood flow, and it often shows up as a stomach problem hours later instead of as plain thirst. Getting your fluid and electrolytes right is usually what fixes the nausea that keeps coming back mid-race. Dial in your personal numbers with the calculators below and rehearse them so race day is a repeat, not an experiment.