I have to send node content by mail using an API. I manage to load and render the content to use it with my API class, and to send it. But when Drupal render the node, all URLs and image SRC are relatives, and it can't be used in a mail.
Here is the code I got so far
$node = \Drupal::entityTypeManager()->getStorage('node')->load($test_node); // $test_node is a (integer) NID
$renderBuilder = \Drupal::entityTypeManager()->getViewBuilder('node');
$node_view = $renderBuilder->view($node, $view_mode); // $view_mode is define in my admin settings
$html = \Drupal::service('renderer')->render($node_view); // I also tried renderRoot and renderPlain
dump($html); // URLs are relatives
exit;
I really search for days now, and I cannot figure how to tell Drupal Renderer to use absolute URL to generate the HTML string.