hook_entity_view_alter - redirect
Instead of using header redirect try using RedirectResponse class which comes together with the Symfony HttpFoundation.

use Symfony\Component\HttpFoundation\RedirectResponse;

 function my_menu_callback_foo() {
    //....
    return new RedirectResponse(\Drupal::url('user.page'));
 }


Refer link for more details.