This is probably most likely with a PoD before 1900, so I stuck it here.
From reality, we have the capital of the Portuguese Empire in Rio de Janeiro during the Napoleonic Wars. The return to Lisbon likely contributed to the desire for independence in Brazil, so I can imagine that remaining in Rio would not please the people of Portugal.
Could an alternate Napoleonic War lead to an invasion, and the British royals escaping to Canada, and ruling from there? After a generation or two, there is a reconquest of the British Isles, but the capital remains in Canada.