Get Absolute url using hook_preprocess_node
In order to get this to work, I did the following. This assume you have access to the $node object, which you would if you are performing this within the hook_preprocess_node() hook. 

$variables['url'] = $node-&gt;toUrl()-&gt;setAbsolute()-&gt;toString();