Praise be to Allah, and peace and blessings be upon the Messenger of Allah.
Reports concerning the unseen must be met with faith and submission, and we should not burden ourselves with asking how they will occur beyond what has been conveyed by revelation, because the conditions of the Hereafter differ from those of this world.
It has been authentically established that the sun will draw near to creation on the Day of Judgment by the distance of one mile. We therefore believe in this as the Prophet ﷺ informed us, and we do not compare the conditions of that day with the worldly laws that we know.
As for how people will endure this proximity, their bodies on the Day of Judgment will be resurrected in a form and with an ability different from their condition in this world, and Allah تعالى will prepare them to withstand the horrors of that day.
Evidence that the conditions of bodies will differ on the Day of Judgment includes the fact that people will remain standing on that day for a very long period—whose measure is fifty thousand years—without needing food and drink in the manner that human beings need them in this world.
Therefore, it is not correct to compare the ability of the bodies of the people gathered on that day to endure the sun with what we know about the ability of bodies in this world, because bodies on the Day of Judgment will have a different condition.
The duty regarding matters of the unseen is to say: We believe and affirm, and not to burden ourselves with trying to know the manner of things that Allah and His Messenger ﷺ have not explained.
And Allah knows best.