Hangovers are pain because of the killer headache. This is caused by the thin layer around the brain to shrink because of dehydration, creating a brain which is pushed inward on all sides. This hurts.
So, how do we solve it? Preventing dehydration. Drink water BEFORE going to sleep. And sleep DEEPLY. Else you are going to vomit a lot. Water makes your stomach unstable. So if you don't want to puke the next morning don't drink water then. Drink mildy hot tea and juices. Food is good too, but don't eat too many different colours, that's not fun to watch the next morning