Fix issue where token is not set on page refresh