Upvote:2
According to TIMATIC, for citizens of Nigeria, transiting without a visa is possible for holders of confirmed onward tickets for a maximum transit time of 24 hours, and provided that they do not leave the international transit area of the airport. A visa would be required should you need to transit between Dubai International Airport (DXB) and Dubai Al Maktoum International (DWC).
For Cuba, Nigerian passport holders are visa exempt for up to 72 hours with proof of the onward flight and the necessary documents for the next destination.
If, as @Calchas has pointed out, your itinerary has additional transit points, you can use the Timatic tool to check requirements yourself.
Timatic is what is used by airlines to verify passengers travel document requirements for their destination and any transit.