Pass base urls to the API app

This gives the API a simple way of knowing where the main application is hosted and where the API is mounted within it. This is used to generate links in the API output.

Part of #268 and #290.