I have an API in Sitecore that takes content from Sitecore and provides it to an external non-Sitecore site. While retrieving content, the API renders a rich text field using a glass mapper. This rich text content may contain "internal links" back to my Sitecore sites. Some of these internal links are rendered as absolute and some as relative links depending on which Sitecore site I am linking to. But any URLs in that content that are relative will fail on the external site. How do I force either Glass Mapper or Sitecore's Field Renderer to always render absolute URLs? I don't mind if this is a global setting.
More context
I have two domains in Sitecore with A and B. The API and main site run on domain A. If I link to site-A in my rich text field the URL renders as relative. Perhaps Sitecore sees this as the same site link. However, if I link to a page on site-B in my rich text field, since the API is hosted on site-A. Sitecore is smart enough to render this site-B link as an absolute URL since it's going across domains. What I'd like to do is always render absolute URLs regardless of where the link is going. Because my external site won't handle relative URLs well. I guess I could solve this with post-processing. Find and replace any relative URLs after the fact with the site-A domain. But I was wondering if there is a more "Sitecore" way to solve this.
Sitecore.Links.DynamicLink.ExpandLinks(string text, bool resolveSites)
andLinkManager.ExpandDynamicLinks(string text, bool resolveSites)
If you're wanting to actually render fields, you can add a rendering helper that returnsnew HtmlString(!string.IsNullOrEmpty(value) ? (expandLinks ? DynamicLink.ExpandLinks(value) : value) : value);