You should use **friendly.api.base_url** parameter
Maybe you should move all of this in a compiler pass...?