Bosnia has a 20km coastline with only one town along it (Neum); this stretch of coastline actually severs the very southern tip of Croatia from the rest of the country, although Croatia has just (as of 2022) completed a bridge that connects the two pieces. The reason for this goes back to 1699; at the time, the Republic of Venice controlled most of the Dalmatian coastline, but not the Ragusan Republic, which was a vassal of the Ottoman Empire. Because the Ragusan Republic had been bullied and pushed around by the Republic of Venice, they insisted that they did not want their territories to abut. So, as part of the treaty concluding the Austro-Ottoman War of 1863–97, the Ottomans were granted two corridors to the coast either side of Ragusa (now Dubrovnik): the Neum corridor to the north, and the Sutorina corridor to the south. As a result of the Napoleonic conquest both Venetian and Ragusan Republics were subsumed into the Austro-Hungarian Empire, but these corridors remained Ottoman.
After WW1, this whole area became part of Yugoslavia. The pre-WW2 Kingdom of Yugoslavia dispensed with the old borders entirely, while post-WW2 “socialist” Yugoslavia brought them back, for unclear reasons. The Neum corridor was part of Bosnia, while the Sutorina corridor became part of Montenegro (which it was adjacent to anyway on the other side). At the time, of course, the borders were essentially meaningless anyway, because Croatia, Bosnia and Montenegro were all part of the same country with no border controls between them. With the breakup of Yugoslavia, of course, that changed. Bosnia retained the Neum corridor, with the result that Croatians travelling from Dubrovnik north had to cross two sets of border controls (a situation that will now change with the new bridge). Montenegro kept Sutorina, although Bosnia actually claimed sovereignty over it until agreeing to stop in 2015.