Ibn ʿAbbas said, "Messenger of Allah ﷺ travelled in the month of Ramadan and he fasted till he reached (a place called) 'Usfan, then he asked for a tumbler of water and drank it by the daytime so that the people might see him. He broke his fast till he reached Mecca." Ibn ʿAbbas used to say, "Allah's Apostle fasted and sometimes did not fast while traveling, so one may fast or may not (on journeys)"
سَافَرَ رَسُولُ اللَّهِ ﷺ فِي رَمَضَانَ فَصَامَ حَتَّى بَلَغَ عُسْفَانَ ثُمَّ دَعَا بِإِنَاءٍ مِنْ مَاءٍ فَشَرِبَ نَهَارًا لِيُرِيَهُ النَّاسَ فَأَفْطَرَ حَتَّى قَدِمَ مَكَّةَ قَالَ وَكَانَ ابْنُ عَبَّاسٍ يَقُولُ صَامَ رَسُولُ اللَّهِ ﷺ فِي السَّفَرِ وَأَفْطَرَ فَمَنْ شَاءَ صَامَ وَمَنْ شَاءَ أَفْطَرَ