The immigration rules say at paragraph 28A(b) that you must be living
in the country where you apply, and that this means that:
when [the applicant] was given authority to live in that country or territory he was given authority to live in that country or territory for a period of more than 6 months.
So this would not include someone who was visiting the country.
https://www.gov.uk/guidance/immigration ... -in-the-uk
However the Entry Clearance guidance "ECB05: Where to apply, the policy" is much less strict and says you can apply at
any visa application centre, British diplomatic mission or consular post overseas where entry clearance applications are accepted.
You should be present legally in the country or territory you’re applying from.
We have to assume that this is a concession, because it is not what the immigration rules say.
I do not give immigration advice. I refer you to Immigration Rules, guidance, other online content and to your sponsor.