You'll just have to plan ahead. Build up stockpiles. Post long-term buy orders. Appoint stewards. Talk to traders.
And after all that, if you still can't manage to keep your city fed while you go on a three-week jaunt away from any marketplace at all, then maybe you just shouldn't spend all that time away from your city. All that extra gold, power, and prestige doesn't exactly come with no strings attached.