How use Basic authorization in API Action on frontend

At the end of a long search, I found a way around the problem, but I still didn’t understand the reason :frowning: