Custom URL provider returning absolete URL

In a v17 project using headless setup, I want to implement at custom URL provider to replace hostname with frontend domain.
I reported an issue here, but it was closed:

It seems there were a similar issue here:

Kenn suggested this, which also works as it is a relative URL:

using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;

namespace Umbraco.Cms.Web.UI.Custom;

public class MyUrlProvider : IUrlProvider
{
    public string Alias => "MyUrlProvider";

    public UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current) =>
        new(new Uri($"/{content.Key}", UriKind.Relative), Alias, culture);

    public IEnumerable<UrlInfo> GetOtherUrls(int id, Uri current)
        => [];

    public Task<UrlInfo?> GetPreviewUrlAsync(IContent content, string? culture, string? segment)
        => Task.FromResult<UrlInfo?>(null);
}

using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Routing;

namespace Umbraco.Cms.Web.UI.Custom;

public class MyUrlProviderComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
        => builder.UrlProviders().InsertBefore<NewDefaultUrlProvider, MyUrlProvider>();
}

However when I implement the following the route is not shown in back office links box although GetUrl returns the UrlInfo as expected.

public class ExternalUrlProvider : IUrlProvider
{
    public string Alias => "ExternalUrlProvider";

    public UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current)
    {
        if (content.ContentType.Alias != ExternalPage.ModelTypeAlias)
        {
            return null;
        }

        var externalUrl = content.Value<string>("externalUrl", culture);

        if (!string.IsNullOrWhiteSpace(externalUrl) && Uri.TryCreate(externalUrl, UriKind.Absolute, out var externalUri) && externalUri is not null)
        {
            return UrlInfo.FromUri(externalUri, Alias, culture, true);
        }

        return null;
    }

    public IEnumerable<UrlInfo> GetOtherUrls(int id, Uri current)
        => [];

    public Task<UrlInfo?> GetPreviewUrlAsync(IContent content, string? culture, string? segment)
        => Task.FromResult<UrlInfo?>(null);
}

When I simple returns a relative URL it shows up:

public UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current)
{
    if (content.ContentType.Alias != ExternalPage.ModelTypeAlias)
    {
        return null;
    }

    var externalUrl = content.Value<string>("externalUrl", culture);

    if (!string.IsNullOrWhiteSpace(externalUrl) && Uri.TryCreate(externalUrl, UriKind.Absolute, out var externalUri) && externalUri is not null)
    {
        //return UrlInfo.FromUri(externalUri, Alias, culture, true);
       return new(new Uri($"/{content.Key}", UriKind.Relative), Alias, culture);
    }

    return null;
}

In Delivery API the external URL is returned, but always starting with / in route although not a relative URL.