By default AEM rewrites (that means the conversion from a repository path to the path part of a URL) all URLs when they are rendered as part of a HTML response. In this case you don't need to do anything.
There might be cases, where you want to convert a repository path to an URL path within JSON output. Use [1] to rewrite the path.
[1] https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolver.html#map-jav...