Some airports in EU countries (eg Shannon in Ireland) have pre-clearance for passengers to the US at the departure end, ie you go through US passport control first and when you get on the plane it is legally a domestic US flight. This is unusual however, just as Americans typically deal with EU passport control at the EU end rather than before leaving the US.
If you want to avoid dealing with these problems in the airport, the solution is to apply for a visa from the US embassy before departure.