The Supreme Court has held that the Constitution only applies to U.S. territory. That was the whole rationale for putting a prison in Guantanamo Bay - it is not U.S. territory. Technically it is Cuban territory being leased to the U.S.
CBP operates under the policy that U.S. border stations (including at International airports) straddle the border between U.S. territory and not-U.S. territory, hence the 4th Amendment doesn't apply if you haven't yet been granted admission into the U.S. If you're trying to enter the country, their contention is that they can search whatever they damn well want to. The Constitution does state the Federal government shall protect states against invasion, so border searches vs the 4th Amendment pits one section of the Constitution against another. The SCotUS needs to decide which takes precedence, but given that all countries need to protect themselves from unlawful entry in order to maintain their existence, I suspect they'll side with the former.
Ironically, all the court decisions blocking states from protecting their own borders against illegal immigrants (e.g. Texas' and Arizona's laws) work in Trump's favor. Those cases established that the Federal government controls immigration policy and enforcement, not the states. When we had an administration favoring lenient policies towards illegal immigrants, the states had no choice but to comply. Now that we have an administration favoring harsh policies towards illegal immigrants, the states again have no choice but to comply.