Abdullah bin Abbas reported,

The Messenger of Allah ﷺ set out from Medina toward Mecca and was fasting until he reached Usfan. Then he called for water and raised it up with his hands so the people could see, and he broke his fast. He continued without fasting until he arrived in Mecca, and this was during Ramadan.Ibn Abbas used to say, "The Messenger of Allah ﷺ both fasted and broke his fast on this journey, so whoever wishes may fast, and whoever wishes may break his fast."

Bukhari 1948

Sahih

حدثنا موسى بن إسماعيل حدثنا أبو عوانة عن منصور عن مجاهد عن طاوس

عن ابن عباس رضي الله عنهما قال

خرج رسول الله ﷺ من المدينة إلى مكة فصام حتى بلغ عسفان ثم دعا بماء فرفعه إلى يديه ليريه الناس فأفطر حتى قدم مكة وذلك في رمضان فكان ابن عباس يقول قد صام رسول الله ﷺ وأفطر فمن شاء صام ومن شاء أفطر

البخاري 1948صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Fasting
Chapter
Whoever broke his fast while traveling so that people could see him
Numbering
Darussalam 1948
Bukhari 1948