I have a link field, which I can populate with both internal and external links:
/node/123
I'm building an API that parses the node and returns the URL from the link field:
$node->my_field->uri
Which returns internal:/node/123
which makes this URL useless.
If I try using use Drupal\Core\Url;
and Url::fromUri($node->my_field->uri)
, I get a 500 error!
So what is the correct approach for getting a formatted URL, that can parse both internal and external links?